curtis_b Posted March 24, 2006 Share Posted March 24, 2006 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 queryROW 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 queryROW FROM ORIGINAL QUERYROW FROM ORIGINAL QUERY-possible match/related row from nested, 2nd queryROW FROM ORIGINAL QUERY-possible match/related row from nested, 2nd query-possible match/related row from nested, 2nd queryThanks for your help Link to comment https://forums.phpfreaks.com/topic/5697-is-it-possible-nested-queries/ Share on other sites More sharing options...
hitman6003 Posted March 24, 2006 Share Posted March 24, 2006 Yes, it's possible, but I wouldn't recommend it.Use a WHERE clause to limit the mysql return to only what you want, then use a join, left or right depending, to retrieve all of the information in one query. Link to comment https://forums.phpfreaks.com/topic/5697-is-it-possible-nested-queries/#findComment-20323 Share on other sites More sharing options...
curtis_b Posted March 24, 2006 Author Share Posted March 24, 2006 Thanks for the reply, if anyone has code examples to show, I would greatly appreciate it. Curt Link to comment https://forums.phpfreaks.com/topic/5697-is-it-possible-nested-queries/#findComment-20327 Share on other sites More sharing options...
keeB Posted March 24, 2006 Share Posted March 24, 2006 [!--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] tt1INNER [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 https://forums.phpfreaks.com/topic/5697-is-it-possible-nested-queries/#findComment-20344 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.