Left Join Issue (1 Viewer)

FireStrike

Registered User.
Local time
Yesterday, 23:06
Joined
Jul 14, 2006
Messages
69
This is a very complicated query. I have two tables, tblFromBob and tblGenCol.

tblFromBob has the below columns. Sim is the PK.
sim
cat_no

tblGenCol has the below columns. Sim and Generic_col is the PK.
sim
generic_col
Identifier

now what I need is the sim, cat_no, identifier_1, identifier_2.
Identifier_1 = identifier where generic_col = 1
Identifier_2 = identifier where generic_col = 2

I need all the sim, and cat_no in tblFromBob whether there is an identifier in either
generic_col. The query I currently have is below

select tblFromBob.sim, tblFromBob.cat_no, tblGenCol.identifier, tblGenCol_1.identifier
from (tblFromBob LEFT JOIN tblGenCol as tblGenCol_1 ON (tblFromBob.sim = tblGenCol_1.sim)) LEFT JOIN tblGenCol on (tblFromBob.sim = tblGenCol.sim)
where (((tblGenCol.generic_col)=1) and ((tblGenCol_1.generic_col)=2)

The problem is that this is only giving me the lines where Generic_Col = 1 and Generic_Col = 2 exist. I need them all.

Can anyone help with this?

Thank you.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 23:06
Joined
Jan 23, 2006
Messages
15,379
Try changing your AND to OR---- first inclination.

What version of Access?
Can you post a copy in mdb format --- remove anything personal and/or confidential.
Just need enough data to show the problem.
 

Users who are viewing this thread

Top Bottom