2 messages in com.mysql.lists.mysqlnested query alternatives ?
FromSent OnAttachments
Korving06 Mar 2000 05:00 
Jan Dvorak06 Mar 2000 05:20 
Subject:nested query alternatives ?
From:Korving (korv@casema.net)
Date:03/06/2000 05:00:04 AM
List:com.mysql.lists.mysql

hi people

I have learned that mySQL does not enjoy nested queries. Now, what I'ld like to achieve for a PHP3 webpage is this:

select subgroup_id from subgroup where parentgroup_id = (select id from parentgroup where name = 'memory');

now i have to solve it like this:

I store the result of "select id from parentgroup where name = 'memory';" into a variable ($id), and then i run this query: "select subgroup_id from subgroup where parentgroup_id = $id;"

the alternative works of course, but I think it would be more efficient to use 1 query only, because there would be less communication between PHP and mySQL that way, which seems faster to me. Maybe I can only gain 0,03 seconds with 1 query, but that would make me a happy man, since this query might be executed about 500 times in 1 minute or so, which would change 15 seconds.

If there is a way for me to do this in 1 query (maybe mySQL does support nested queries but in a way I'm not aware of), please let me know, since it is very important to me.

Thanks in advance to whoever will reply this :)

Ron abra@patser.net