assume the photos are in a separate table, members are allowed more than one photo, and you want to retrieve the photo that the member has marked as primary
Code:
SELECT member.username
, member.online_status
, COALESCE(photos.photo_name
, 'photo_pending_review.jpg') AS photo
, COALESCE(photos.photo_label
, 'Pending') AS photo_label
, member.first_name
, member.location
FROM member
LEFT OUTER
JOIN photos
ON photos.member_id = member.id
AND photos.primary = 1
AND photos.photo_approved = 1
WHERE member.id = ?
Bookmarks