Forum Moderators: open
In the query below, I am passing it several IDs which I want it to query for. However, if the ID that is being used in the query, is found in the database, I want the query to ignore it. As you can see below, I was trying to do that with the != condition, but to no avail. I also just tried making it so that the != used "AND" conditions between the sets of numbers, but no luck there either.
Any idea what I am doing wrong? The query is still returning 4722, 4723, 4724, 4725, and 4726, but not the previous 5 numbers (4712-4716). I am getting the proper results after the collection of the 4722-4726. So, just need to figure out how to get rid of those.
Thanks in advance!
SELECT node.nid
FROM node
LEFT JOIN content_field_event_category ON ( content_field_event_category.nid = node.nid )
LEFT JOIN content_type_event ON ( content_type_event.field_event_location_nid = node.nid )
LEFT JOIN node_revisions ON ( node_revisions.nid = node.nid )
WHERE node.nid != ( 4712
OR 4713
OR 4714
OR 4715
OR 4716 )
AND node.nid != ( 4722
OR 4723
OR 4724
OR 4725
OR 4726 )
AND (
field_event_category_nid
IN ( 4712, 4713, 4714, 4715, 4716 )
OR field_event_location_nid
IN ( 4722, 4723, 4724, 4725, 4726 )
)
LIMIT 0 , 30
The placement of the arguments as well as changing != to NOT IN and making the numbers into lists like I did in the other two arguments.
SELECT node.nid FROM node LEFT JOIN content_field_event_category ON (content_field_event_category.nid = node.nid) LEFT JOIN content_type_event ON (content_type_event.field_event_location_nid = node.nid) LEFT JOIN node_revisions ON (node_revisions.nid = node.nid) WHERE (field_event_category_nid IN (4712, 4713, 4714, 4715, 4716) OR field_event_location_nid IN (4722, 4723, 4724, 4725, 4726)) AND node.nid NOT IN (4712, 4713, 4714, 4715, 4716) AND node.nid NOT IN (4722, 4723, 4724, 4725, 4726)