Nesting Query Calls
Hi, I am wanting to write a nesting of queries without having to retrieve all the records of the first query (because of the volume). pseudo code, using MySQL 5. alpha/PHP mysqli C connector res1 = query(db, sql1, USE_DATA); while (row1 = fetch_row(res1)) { res2 = query(db, sql2_function_of(row1); row2 = fetch_row(res2, USE_DATA); free_result(res2); } free_result(res1); From my reading this seem to violate two principal I have used elsewhere 1) query 1 is still busy, so I can't begin a query 2 -- can I open a new connection to get around this? 2) I didn't read all the results of query 2, so they may show up somewhere I don't want them? Is there a way to do this, does it work and I am missing something? Thanks, Don. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Nesting Query Calls
Don Huff [EMAIL PROTECTED] wrote on 03/01/2005 02:33:34 PM: Hi, I am wanting to write a nesting of queries without having to retrieve all the records of the first query (because of the volume). pseudo code, using MySQL 5. alpha/PHP mysqli C connector res1 = query(db, sql1, USE_DATA); while (row1 = fetch_row(res1)) { res2 = query(db, sql2_function_of(row1); row2 = fetch_row(res2, USE_DATA); free_result(res2); } free_result(res1); From my reading this seem to violate two principal I have used elsewhere 1) query 1 is still busy, so I can't begin a query 2 -- can I open a new connection to get around this? 2) I didn't read all the results of query 2, so they may show up somewhere I don't want them? Is there a way to do this, does it work and I am missing something? Thanks, Don. The parent-child type of query you want to make is generally accomplished through a JOIN. However, you say you have more data than you want to deal with at one time. Can you be more specific? What is the actual problem you are trying to solve? The more details you can give, the better the combined response will be. Shawn Green Database Administrator Unimin Corporation - Spruce Pine
Re: Nesting Query Calls
Shawn, Yes, I know that is true. With a framework that is properly spread out however, often the inner query does not even know that the outer one is active. The situation: list a bunch of hits from the database to be displayed in a table. 1) the query is constructed and handed to the framework to execute, as rows are returned they are given to the main application to display, however, 2) the main application decides that to properly show this record it must determine a few other things, then create the table row and return control to the framework. It wants to do this by creating a new select statement and running it. It seems this is not possible if the framework tries to use a single global connection to the daemon, yes? no? Can another connection be made? thanks, Don. --- [EMAIL PROTECTED] wrote: The parent-child type of query you want to make is generally accomplished through a JOIN. However, you say you have more data than you want to deal with at one time. Can you be more specific? What is the actual problem you are trying to solve? The more details you can give, the better the combined response will be. Shawn Green Database Administrator Unimin Corporation - Spruce Pine -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]