Jump to content

Recommended Posts

I do my SQL query like normal:

 

<?

$result = mysql_query($query);

while($list = mysql_fetch_array($result)){

      //do stuff

}

?>

 

I would like to do multiple queries, and join them into one $result before starting the while() loop.  Is this possible?   If so, how would I do this on the PHP side?  Or, would I need to format my $query to fetch everything I need in just one query?

You cannot join multile results into one.  If you can use JOIN in your SQL to get all the data in one query, then your problems will be solved.

 

Okay, then I think I need help with my query.

 

these are the two I want to join:

 

SELECT * FROM table WHERE flag='Y'

SELECT * FROM table WHERE flag='N' LIMIT 50

 

So I want to have all with flag=Y and 50 with flag=N all in the same query.

 

Is this easy?

 

There is no logical reason I can think of to combine the two where you would run through them in the same loop.

 

So I want to get a list of all flagged entries, and 50 that are not flagged per execute.  This script will run once per day in a cron job.

 

Of the Flagged entries, (and the 50 that are not flagged), some checks will be done on each.  Based on the check, some of these might be removed from the DB and the remaining will be flagged.

 

This will recursively go through the entire table, until all are either flagged or deleted.  New entries will come in not flagged, and will be checked when it is their turn in the "50 per day".

 

 

Normally, I would do this with 2 separate queries and 2 separate loops.  I want to know if it can be done with one loop?

 

Thanks!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.