Shawn Northrop Shawn Northrop - 1 year ago 58
MySQL Question

What is wrong with this SQL statement - error

SELECT `exp_channel_titles`.`entry_id`
FROM (`exp_channel_titles`)
JOIN `exp_category_posts` ON `exp_channel_titles`.`entry_id` = `exp_category_posts`.`entry_id`
WHERE `exp_category_posts`.`cat_id` IS NULL
AND `exp_channel_titles`.`channel_id` IN (2)
AND `exp_channel_titles`.`entry_id` NOT IN ()

The error is:
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 ')' at line 1

It highlights the
at the end of:

From (`exp_channel_titles`)

If I remove the
I get the same error however it is highlighting the
at the end of

.`channel_id` IN (2)

Answer Source

You can't have an empty IN clause like this entry_id NOT IN (). If you can't remove that condition from your query then you could fill it with values like 0 that are not content of you entry_id column

entry_id NOT IN (0)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download