I have a query here , that im using to pull user information based off a search from my database.
I have another table called shocc_account_photos where i store the photo_filenames of the user's pictures. A user can have more then 1 picture , so i mark their main picture as main = 1
Reminding you , this is a search , so its pulling many records from the database. I have no problem joining shocc_users with shocc_account_photos so i can get the main photo of each user who was returned in the search ... But what if a user doesnt have a main picture? then main=1 wouldnt be true , and they get excluded from the search .. but i still want user's with no pics to showup , but at the same time , I have to use WHERE main=1 to get the photo filename of the people who DO Actually have pictures ... so im really in a bind here ..
Trying to get the photo filenames of the people who have pics , yet at the same time trying to return info on those who dont.
$sql = "SELECT u.city, u.state, u.username,
u.rating,u.age,u.ethnicity,u.gender,u.starsign,
p.photo_filename
FROM shocc_users u
NATURAL LEFT JOIN shocc_account_photos p
WHERE u.username REGEXP '$search_username'
AND u.age >= '$search_low_age'
AND u.age <= '$search_high_age'
AND main=1
$ssql
ORDER BY rand()
Ive tried and tried ... some help would be greatly appriciated
Thank you in advance.