I am trying to Construct a Query to get the Photo Filename from a Table that store's My User's photo filenames.
So far, my query Looks like this.
$sql = mysql_query("SELECT shocc_users.city,shocc_account_photos.photo_filename
FROM shocc_users
LEFT JOIN shocc_account_photos
ON shocc_users.username = shocc_account_photos.username
WHERE
main = 1
");
Now this Would return all the user's city's from my user table, and the filename of their main picture from shocc_account_photo's For each user.
Because i have constructed a Left Table join, if no account photofilename was found then the city is still returned.
Not So.
In my Shocc_account_photo's table, Users can upload upto 13 pics ... So 1 user could have 13 entry's in that table for photo filenames. Only 1 can be the Main photo tho, and this is marked by main = 1
Main being a Colum in shocc_account_photos
Now In our Query above .. We said WHERE main=1 so any user's who dont have a entry in shocc_account_photos for a main pic .. Will be discarded.
Any user who does not have a Main Picture, it wont even return the city back, it Doesnt find a main=1 as needed in the WHERE clause, so it skips over the row.
I dont want that .. If a user doesnt have a picture, that's fine, i still need the information returned for their city .. And as it is right now, any user's that dont have a main picture , might as well not even be users.
How can i fix this to return the photo_filename WHERE main = 1 , but if it cant find a entry for a user where main = 1 it will still return information about the city?