View previous topic :: View next topic
|
Author |
Message |
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
Hi,
I have a query on the below tables.
Code: |
Table A
----------
CL_ID E_NM REC_ID
123 AAA 03
123 BBB 56
123 CCC 78
134 DDD 90
Table B
-----------
CL_ID E_NM E_CODE
123 AAA TT
123 BBB XX
134 DDD ZZ
The result query should be as below
I need to retreive only the results of CL_ID = 123
CL_ID E_NM REC_ID E_CODE
123 AAA 03 TT
123 BBB 56 XX
123 CCC 78 ----
|
I tried to do a left outer join but it gave the results of CL_ID= 134 as well. i dont want that to happen. This is the query i used. please advice how i can modify it to the requirements.
Code: |
select A.CL_ID, A.E_NM,A.REC_ID, B.E_CODE
from Table A left outer join Table B
on
A.E_NM = B.E_NM and
A.CL_ID = B.CL_ID and
A.CL_ID = 123
|
|
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi,
Did you tried this?
Code: |
Select A.CL_ID, A.E_NM,A.REC_ID, B.E_CODE
from Table A left outer join Table B
on
A.E_NM = B.E_NM and
A.CL_ID = B.CL_ID
WHERE A.CL_ID = 123 |
I would suggest to go through the manuals to check how joins work
Regards,
Chandan |
|
Back to top |
|
|
CJT
New User
Joined: 02 Aug 2007 Posts: 83 Location: Here
|
|
|
|
Hi Chandan,
thank you so much. This worked fine for me. |
|
Back to top |
|
|
|