Reputation: 32233
In a table [id, credit, debit] (all the values are integer)
I have (id1,id2,id3....) and (idA,idB,idC...).
I want to put all credit values to 0 for the ids (id1,id2,id3....) and all debit values to 0 for the ids (idA,idB,idC...). Is that possible in a single query or I must make two consecutive update queries?
Upvotes: 0
Views: 638
Reputation: 8312
It may be possible to do simething like:
UPDATE table
SET credit =
CASE id IN (id1,id2,id3)
THEN 0
END,
debit =
CASE id IN (idA,idB,idC)
THEN 0
END
Although I think 2 queries would be easier to write and easier to understand
Upvotes: 1
Reputation: 18489
You may need two queries because in one query only one where clause can be there.Not more than one.As you have two conditions you may need 2 queries.
Upvotes: 1