Here is some hardcoded syntax. IPAddr is an int, this is sqlite and will be ported to mysql.
The syntax doesnt work with AND V.IPAddr <> 0
. Possibly because V is a left join and may not exist (null?). How do I get it to to succeed when V == null || V.IPAddr <> Val
?
select Post.id, name, body,
(select count() from Votes where id=Post.id AND (type & 4)<> 0) as DV
from Post
left join Votes as V on V.id=Post.id
where flag='1' AND V.IPAddr <> 0 AND DV<1
limit 1