Thread: subqueries vs. separate queries
Is there much difference between using subqueries and separating out them into separate queries? __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/
CSN wrote: >Is there much difference between using subqueries and >separating out them into separate queries? > > That would depend on what results your expecting, and how you intend on using the results. For example if you want all the data in a single statement, you can't break it up, but the request will likely use more resourcesto complete. If your application can cut and paste the data from multiple transactions, then simple queries may need less resources tocomplete, but remember that your application will require resources to cut and paste the results as well. I have written a number of PHP functions that uses an array the results of a query to generate formatted html tables, graphsand statistical information. It is easiest to use a single complex query with subqueries, but it is possible to 'fake'a complex query by 'stacking' multiple results into an array. Hope that helps.
cool_screen_name90001@yahoo.com (CSN) writes: > Is there much difference between using subqueries and separating out > them into separate queries? Yes. No. Maybe. What kind of difference are you thinking about? If you join queries together, you wind up with fewer queries, and your outside code that manipulates the results will likely have less work to do. There are certainly notions of "efficiency" and "simplicity" that can out of that. By the same token, those fewer queries are sure to be a bit more complex, may be more difficult to write and understand, and may poke at "edges" of the query optimizer such that they _may_, if you are very unlucky, run unexpectedly slowly. It is quite possible for the simplifications of your application to outweigh the _possible_ costs... -- output = ("cbbrowne" "@" "ntlug.org") http://cbbrowne.com/info/linux.html Would-be National Mottos: USA: "We don't care where you come from. We can't find our *own* country on a map..."