wjhulzebosch Posted October 2, 2011 Share Posted October 2, 2011 Hi, i've got a website with images on it. You can tag the images, and after that, you can view images with a certain tag. I have the following tables: table:filelist ------------------------------------- picnum | filename | complaint ------------------------------------- 1 | fam.jpg | 0 2 | dog.jpg | 0 3 | cat.jpg | 0 table: tags ----------------------------- picnum | tag | ok ----------------------------- 1 | Family | 1 1 | Jonathan | 1 2 | Dog | 1 2 | Animals | 1 This works with this piece of code: $result_n = mysql_query( "SELECT picnum, filename, tag FROM filelist LEFT JOIN tags ON (picnum = tags_picnum) WHERE tag='$tag' AND ok='1' AND complaint=0"); Now, i want to create a page where i can see all images, without a tag (in this example, image 3, cat.jpg). Is the above piece of code easy to convert to find images that have no tag associated with them? How can i easily find images without a tag? Ty! Link to comment https://forums.phpfreaks.com/topic/248277-join-where-field-is-empty/ Share on other sites More sharing options...
awjudd Posted October 2, 2011 Share Posted October 2, 2011 SELECT picnum, filename FROM filelist f LEFT JOIN tags t ON f.picnum = t.picnum WHERE t.picnum IS NULL ~juddster Link to comment https://forums.phpfreaks.com/topic/248277-join-where-field-is-empty/#findComment-1275021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.