RE: [PHP] sql: subselect howto?

From: Date: Wed, 09 Aug 2000 22:26:22 +0000
Subject: RE: [PHP] sql: subselect howto?
Groups: php.db php.general 
Request: Send a blank email to php-db+get-1915@lists.php.net to get a copy of this message
(this should be on a SQL list, as this is completely unrelated to PHP) Couldn't you do this? SELECT items.item, items.userid, users.name FROM items LEFT JOIN users ON items.userid=users.userid WHERE users.name LIKE 'm%' --Bruce Bruce Christensen Intel Corporation brucex.r.christensen@intel.com -----Original Message----- From: Dieter Kneffel [mailto:data@wap4.com] Sent: Wednesday, August 09, 2000 2:56 PM To: php-db; php-general Subject: [PHP] sql: subselect howto? Can someone please give an example of a subselect! It should be sufficient to show really basic usage, I'll figure out the rest. Just can't test it now as I haven't access at the moment to the (Oracle8) database the code is intended for. My first suggestion goes here, please apply necessary fixes! -- Imagine we have two really basic tables: 'items' and 'users'. items has 2 cols: 'item' (int) and 'userid' (int) users has 2 cols: 'name' (char) and 'userid' (int) Now lets say, I need to show all 'name's and 'item's that belong to users with an 'm' as the first letter in their name ('name' from table users) select item,userid from items where userid in (select userid from users where name like 'm%'); Probably this returns only 'item' and 'userid' ??? So, how do I also get the corresponding 'name' values returned? As stated above, this is meant for educational purposes. I know how to do it (e.g. in MySQL) using two separate queries, so please reply only if you can help with the subselect. Thank you very much, Dieter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#1915) next »