For a messaging system, I'm trying to mark the appropriate to_del and from_del fields for employee 2.
Here is before employee 2 deletes messages:
company_id | to | from | to_del | from_del
1 4 2 0 0
1 2 4 0 0
Here is after employee 2 deletes messages:
company_id | to | from | to_del | from_del
1 4 2 0 1
1 2 4 1 0
I have to run 2 queries for this to work:
UPDATE messages SET from_del='1' WHERE company_id=1 AND from=2
UPDATE messages SET to_del='1' WHERE company_id=1 AND to=2
Is there anyway to merge these 2 queries into 1 more efficient query? Something like:
UPDATE messages SET from_del='1',to_del='1' WHERE company_id=1 AND (from=2 OR to=2)
This single query's issue is that it marks all 4 delete fields as '1'. Any ideas on how to get a single efficient query to act like the 2 above queries?