Q:

How to combine two unrelated SQL queries

Let's say I have two SQL queries:
INSERT INTO tableA VALUES ('', 'mike', '21')

DELETE FROM tableB WHERE name = 'john'

And I want to execute them at the same time. How do I do that?
I know that UNION only works for SELECT statements, so it's useless in this case.

A:

You create a transaction.
http://dev.mysql.com/doc/refman/5.5/en/commit.html
START TRANSACTION;
  INSERT INTO tableA VALUES ('', 'mike', '21');
  DELETE FROM tableB WHERE name = 'john';
COMMIT;

