Welcome to WebmasterWorld Guest from 23.22.250.113

Forum Moderators: open

Message Too Old, No Replies

left join with extra conditions

trouble with left join and extra conditions

     

frankstuner

4:29 pm on Dec 15, 2012 (gmt 0)



I'm trying to setup a rating app for images. I want to display the images that haven't been rated by the current logged user.

This covers two tables, I've successfully joined the tables but the extra conditions:
1. must be an image
2. exclude any images that have already been rated by the current user
are not working.

Its displaying the results as if the 2 AND conditions aren't there at all.

SELECT ver_data_media.id, ver_data_media.value, ver_data_media.ref, ver_data_media.type, ver_data_rating.a
FROM ver_data_media
LEFT JOIN ver_data_rating
ON ver_data_media.ref = ver_data_rating.a
AND ver_data_media.type = 'image'
AND ver_data_rating.a != $current_user->ID


Any advice would be greatly appreciated, thanks Frank.

LifeinAsia

5:53 am on Dec 17, 2012 (gmt 0)

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Try:
SELECT ver_data_media.id, ver_data_media.value, ver_data_media.ref, ver_data_media.type, ver_data_rating.a
FROM ver_data_media
LEFT JOIN ver_data_rating
ON ver_data_media.ref = ver_data_rating.a
WHERE ver_data_media.type = 'image' AND ver_data_rating.a != $current_user->ID
 

Featured Threads

Hot Threads This Week

Hot Threads This Month