11-24-2010, 07:46 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: May 2009
Posts: 178
Thanks: 9
|
JOIN query
I'm trying join 2 tables and think I require a LEFT join as all rows in table1 are required but struggling to handle the rules associated with table2. Looking for some help/guidance. My tables are basically:
TABLE1
userid. user
1. Mr Smith
2. Mr Davis
3. Mrs Jackson
TABLE2
imageid. Main_image. userid
23. Y 1
24. N. 1
25. Y. 2
I'm looking for a query that will return every row in table1 then rows associated in table2 assuming the main_image flag is set to Y.
I've done a left join but when append AND main_image = Y i lose rows from table1 that don't match that criteria I.e. User 3. How can I pull all users from table1 then pull in all main_images from table2?
Hope u get the gist having trouble easily documenting this as typing it on an iPhone but any help greatly appreciated.
|
|
|
|