Reputation: 47
In MySql, I try to do an UPDATE and a SELECT in the same query. I have try many examples from this site, but nothing work. (Variables, sub-query...)
UPDATE receipt
SET status = IF(status=1, 0, 1)
WHERE idreceipt = 220
SELECT status
FROM receipt
WHERE idreceipt = 220
Thank you
Upvotes: 1
Views: 642
Reputation: 4453
If the above commands are fine for you as they are, just enter the semicolons at the end of the statements:
UPDATE receipt
SET status = IF(status=1, 0, 1)
WHERE idreceipt = 220;
SELECT status
FROM receipt
WHERE idreceipt = 220;
Upvotes: 2