Hey i am doing an n8n automation and i have problem with mysql execute query

Hi there guys i need help with my automation.
I have given my database schema to my ai agent which generates queries according to the database schema
And i execute it in my mysql node
The problem is that sometimes the agent generates two queries, but the second query is dependent on the first queries result then how am i going to execute the first query and get the result and then again run the second query

Hey! You’ll need to split the AI output into two steps in n8n. Use one MySQL node to run the first query, then pass its result into a second MySQL node for the second query. You might also need a Function or Set node in between to format the input if the second query depends on a value (like an ID) from the first. Let me know if you want help structuring that flow!

Ask ChatGPT

i got another way where it was way easy
the previous workflow had an problem where i couldn’t decide how many query can be there as there can be a number of sub queries but this workflow which was already present in one of the free templates by n8n helped me i need not worry about it now
Thanks though