Question about posting multiple queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apusateri
    New Member
    • Oct 2006
    • 27

    Question about posting multiple queries

    Good morning (afternoon, evening, whatever),

    I realize this is PHP as well as MySQL, but I had to make a judgement call on where to post the question, hope that's okay...

    Is there any way to run multiple SQLQuery statements to the same array of results?

    For example:

    Code:
    $SQLQuery = "SELECT * FROM SOMETHING WHERE SOMETHING='TRUE';";
    
    $result = mysql_query($SQLQuery);
    $this->numRows = mysql_numrows($result);
    
    // Assign all values to variables
    $i = 0;
    while ($i < numRows)
    {
         $this->something1 = mysql_result($result, $i, "SOMETHING");
         // etc...
    }
    The code above works fine for one query, but is there a way for me to query a different set of records in the same database and insert them into the same records array?

    Any help would be appreciated. Thanks.
  • b1randon
    Recognized Expert New Member
    • Dec 2006
    • 171

    #2
    Originally posted by apusateri
    Good morning (afternoon, evening, whatever),

    I realize this is PHP as well as MySQL, but I had to make a judgement call on where to post the question, hope that's okay...

    Is there any way to run multiple SQLQuery statements to the same array of results?

    For example:

    Code:
    $SQLQuery = "SELECT * FROM SOMETHING WHERE SOMETHING='TRUE';";
    
    $result = mysql_query($SQLQuery);
    $this->numRows = mysql_numrows($result);
    
    // Assign all values to variables
    $i = 0;
    while ($i < numRows)
    {
         $this->something1 = mysql_result($result, $i, "SOMETHING");
         // etc...
    }
    The code above works fine for one query, but is there a way for me to query a different set of records in the same database and insert them into the same records array?

    Any help would be appreciated. Thanks.
    One way to do what you are talking about would be to use a stored procedure. In your stored procedure you can run any number of queries and append them all to the same result set before returning it. Here's a link to the documentation on stored procedures.

    Comment

    Working...