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
https://forums.phpfreaks.com/topic/5697-is-it-possible-nested-queries/
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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.