I have a database with properties and I need to delete all the properties except for those "owned" by either one of 3 "Inscription Agents". Each property can have up to 2 "owners": agent_inscripteur_1 and agent_inscripteur_2 on the database.
This is my code:
DELETE FROM inscriptions
WHERE (agent_inscripteur_1 != 100520 OR agent_inscripteur_2 != 100520)
AND (agent_inscripteur_1 != 97927 OR agent_inscripteur_2 != 97927)
AND (agent_inscripteur_1 != 99237 OR agent_inscripteur_2 != 99237)
I think what is happening in my case is that the first part of the code before the AND is executed before the rest, so all properties except for those listed by the first agent are being deleted (by the time it gets to the second and third agent, the properties are all gone).
Can someone please point me in the right direction?
Thanks!
CASEis an exception for a couple of reasons...). Since for each row at least one of the sub-conditions will (likely) be true, the row is deleted. DBs do this for a couple of reasons: 1) it's actually due to dbs thinking in "sets", essentially matching records 2) it allows the db to choose which condition to evaluate first, allowing queries to be faster.