472,119 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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:

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.
Jan 3 '07 #1
1 1325
b1randon
171 Expert 100+
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.
Jan 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Geoff Berrow | last post: by
4 posts views Thread by inline_four | last post: by
3 posts views Thread by Simon Harvey | last post: by
1 post views Thread by Chris M. | last post: by
35 posts views Thread by Stan Sainte-Rose | last post: by
5 posts views Thread by Regnab | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.