Reputation: 395
Is it be possible to update two tables writing a single query?
So that i do not have to execute two queries and to track whether both are successful?
Upvotes: 4
Views: 1160
Reputation: 28180
You could use transactions, however you are still required to update the tables separately and check the results before committing or rolling back.
Upvotes: 0
Reputation: 102468
You can write a stored procedure that updates the two tables and returns whatever you need it to in order to determine success. This stored proc can then be called from a single command. However, it will still have to contain two queries.
Upvotes: 1
Reputation: 6029
You can't do it in a query but you can do it as a transaction when all queries within the transaction will either succeed or fail.
Upvotes: 3
Reputation: 33476
No, that is not possible AFAIK.
EDIT: What is the reason for you to achieve this in a single query?
Upvotes: 0