Connecting Tech Pros Worldwide Forums | Help | Site Map

Question about posting multiple queries

Newbie
 
Join Date: Oct 2006
Location: Mesa, AZ
Posts: 27
#1: Jan 3 '07
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:

Expand|Select|Wrap|Line Numbers
  1. $SQLQuery = "SELECT * FROM SOMETHING WHERE SOMETHING='TRUE';";
  2.  
  3. $result = mysql_query($SQLQuery);
  4. $this->numRows = mysql_numrows($result);
  5.  
  6. // Assign all values to variables
  7. $i = 0;
  8. while ($i < numRows)
  9. {
  10.      $this->something1 = mysql_result($result, $i, "SOMETHING");
  11.      // etc...
  12. }
  13.  
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's Avatar
Expert
 
Join Date: Dec 2006
Location: Pittsburgh
Posts: 171
#2: Jan 3 '07

re: Question about posting multiple queries


Quote:

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:

Expand|Select|Wrap|Line Numbers
  1. $SQLQuery = "SELECT * FROM SOMETHING WHERE SOMETHING='TRUE';";
  2.  
  3. $result = mysql_query($SQLQuery);
  4. $this->numRows = mysql_numrows($result);
  5.  
  6. // Assign all values to variables
  7. $i = 0;
  8. while ($i < numRows)
  9. {
  10.      $this->something1 = mysql_result($result, $i, "SOMETHING");
  11.      // etc...
  12. }
  13.  
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.
Reply