View Single Post
Author Message
AnIHiL
Member
Join Date: Sep 2009
Old 08-19-2011 , 16:01   Multiple ordered SQL queries
Reply With Quote #1

I checked all topic related to MySQL queries but I didn't find out how to solve my problem.

How can I make 3-4 SQL threaded queries but they should run in exact order:
1. Query 1 -> give results
2. Query 2 -> give results
...

Query 2 should be executed after I get all results from query 1.

I can make something like this:

Code:
SQL_TQuery(hdatabase, Q1Res, query1, userid);

public Q1Res(Handle:owner, Handle:hndl, const String:error[], any:data)
{
    // get results
    ...
    SQL_TQuery(hdatabase, Q2Res, query2, userid);
}

public Q2Res(Handle:owner, Handle:hndl, const String:error[], any:data)
{
    // get results
    ...
    SQL_TQuery(hdatabase, Q3Res, query3, userid);
}

public Q3Res(Handle:owner, Handle:hndl, const String:error[], any:data)
{
    // get results
    ...
    SQL_TQuery(hdatabase, Q4Res, query4, userid);
}

public Q4Res(Handle:owner, Handle:hndl, const String:error[], any:data)
{
    // get results
    ...
}
But as you can see this code will be very complicated if I insert more queries there.

Is there any other solution how to solve it?
AnIHiL is offline
Send a message via MSN to AnIHiL