Well, I was trying to select rows from one table if there are no rows in another table.
My original query was:
SELECT * FROM `jos_datsogallery` as a WHERE a.published = 1
and a.approved=1 NOT EXISTS (SELECT * FROM `jos_datsogallery_votes`
As v WHERE v.vip=62 AND v.vpic=a.id) ORDER BY a.imgdate DESC
but it keeps failing.
I made some testing and shortened my query to:
SELECT * FROM `jos_datsogallery` WHERE EXISTS (SELECT 1)
Which is supposed to select everything from jos_datsogallery as 'EXISTS (SELECT 1)' is always true.
I tried phpMyAdmin:
1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'EXISTS (SELECT 1) LIMIT 0, 30' at line 1
What's wrong?
MySQL version: 4.0.27
MySQL doc: http://dev.mysql.com/doc/refman/4.1/en/exists-and-not-exists-subqueries.html