There are two possible solutions depending on what you are allowed to do with your db server.
-
If you have create permissions to your MySQL server the best thing is to create a stored procedure to run all of your queries. This is by far the best solution. I find stored procedures (especially in SQL Server) quite painful, but I am getting better at sucking it up and doing it anyway.
-
If you cannot do 1) then you can split q1 into multiple queries and run them sequentially using the technique shown here: A pattern for triggering many async queries