I need a sql statement, to insert a new row in one database table and update an existing row in another database table based on some conditions.
Is there a way to do this? To insert a row in one table and update a row in another database table in one sql statement?
Thanks in advance!
Yes, they are called Transactions, and are implemented with
START TRANSACTION and COMMIT/ROLLBACKwith something like:EDIT
This is not in fact one SQL query, but the operation is done atomically – and I think that is what you need.