• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

mySQL multiple queries

Stuart

Member
Hi,
is there any way to send multiple queries at once, like the way you can do with php or in the 'console' by separating them with a semicolon?
There are times that I want to be sure my queries are processed together etc.
Thank you!
 

ArshilAhmad

Moderator
Staff member
Hi @Stuart,

Could you please create a brief screen recording and provide further elaboration on this specific concern? This will help us gain a better understanding and assess the feasibility of your use case.
 

Stuart

Member
a few examples off the bat:
1) where I want either both transactions to succeed or both fail:
Code:
START TRANSACTION;
INSERT INTO table1 (column1) VALUES ('value1');
INSERT INTO table2 (column2) VALUES ('value2');
COMMIT;
2) or in a case where I want to do multiple things with the same data:
Code:
INSERT INTO table1 (column1, column2) VALUES (value1, value2);
UPDATE table2 SET column1 = value1 WHERE condition;
DELETE FROM table3 WHERE condition;
3) multiple selects where ARRAYAGG or UNION won't work ( for example, because there are different number of columns in each table)
Code:
SELECT * FROM clients WHERE client_id = '1';
SELECT * FROM cases WHERE case_client_id ='1';
4) procedures
Code:
DELIMITER //
CREATE PROCEDURE procedure_example()
BEGIN
    SELECT * FROM table1 WHERE condition1;
    UPDATE table2 SET column1 = value1 WHERE condition2;
END //
DELIMITER ;
I am sure there are many more (security, log or audit layers)
 
P

Pabblymember11

Guest
In a standard SQL execution environment, each statement—be it INSERT, UPDATE, or DELETE—executes sequentially when submitted together as part of a single batch or script. Please give it a try at your end and let us know.
 

Stuart

Member
I have tried it and get an error like this, even though each statement by itself works
1715957441253.png


1715957661411.png
 

Stuart

Member
something else I want to do via mySQL is checklists, that would return back if the list was complete when a check item is marked.
 

ArshilAhmad

Moderator
Staff member
Please allow me some time to discuss the possibility of this use case with my team. We will get back to you with and update soon.
 

Stuart

Member
Thank you, however that is a single query inserting multiple rows of data, whereas the ones here are multiple related queries chained together as mySQL allows with a semicolon.
where for example I want to insert a new client and case at the same time, but if one should fail the other one will also so as not to cause a cascade of failures when other automations come into play. or if I want to reference the previous query like
Code:
SELECT LAST_INSERT_ID();
where I would want to be sure that no one else accessed the database between the queries.
 

ArshilAhmad

Moderator
Staff member
I had a discussion with the technical team, and they informed me that it’s not possible to run multiple related queries in the same action step. They can only run in separate action steps.
 
Top