SQL is all about using *sets*.
Even though most dialects of SQL give you ways to iterate through individual items in your "select", it's almost always a Bad Idea to fetch anything besides a complete set at the server (then feel free to iterate to your heart's content, if need be, once you get the result set back to the client).
As pointed out above:
Quote:
for (select id from tablename)
select colName from tablename2 whereid="id_from_current_iteration";
-- Different databases usually have different SQL extensions that let you do this ... but you *shouldn't* (at least not directly from SQL)
|
Quote:
select colName from tablename2 whereid in (select id from tablename);
-- Much, much better
|
Here's a good article that explains further:
http://www.paragoncorporation.com/Ar...x?ArticleID=27