select a.*
from article as a
where a.status_id = 2 and count(select h.id from article_history as h where h.article_id = a.id and h.event_id = 5) = 0
[Err] 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 'select h.id from article_history as h where h.article_id = a.id and h.event_id =' at line 3
id
count(select h.id from article_history as h where h.article_id = a.id and h.event_id = 5)
на(select count(h.id) from article_history as h where h.article_id = a.id and h.event_id = 5)
? Хотя поидее смысл тот жеCOUNT
нельзя использовать вWHERE
: только вSELECT
и вHAVING
.