| left join with extra conditions trouble with left join and extra conditions |
frankstuner

msg:4528445 | 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

msg:4528879 | 5:53 am on Dec 17, 2012 (gmt 0) | 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
|
|
|