Jump to content

Is it possible.... nested queries


curtis_b

Recommended Posts

I'm wondering if this is even possible, and if so, can someone point me in the direction of a good example....

Once a select query has been sent to mysql and in the while (fetch array) loop, I want to then send another select query/while loop to a different mysql table based on the current row value for a column in the first query. Sorry if that sounded confusing I don't know how else to explain it. The resulting output I'm trying to acheive would have the following structure:

ROW FROM ORIGINAL QUERY
-possible match/related row from nested, 2nd query
ROW FROM ORIGINAL QUERY
-possible match/related row from nested, 2nd query
-possible match/related row from nested, 2nd query
-possible match/related row from nested, 2nd query
-possible match/related row from nested, 2nd query
ROW FROM ORIGINAL QUERY
ROW FROM ORIGINAL QUERY
-possible match/related row from nested, 2nd query
ROW FROM ORIGINAL QUERY
-possible match/related row from nested, 2nd query
-possible match/related row from nested, 2nd query

Thanks for your help
Link to comment
Share on other sites

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * [color=green]from[/color] [color=orange]tblTable1[/color] tt1
INNER [color=green]JOIN[/color] tblTable2 tt2 on tt2.someID [color=orange]=[/color] tt1.someID
[color=green]WHERE[/color] tt2.someID [color=orange]=[/color] 2
[!--sql2--][/div][!--sql3--]

Make any sense?
Link to comment
Share on other sites

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.