AW: [PHP-DB] SQL Select statement

From: Date: Sat, 17 Feb 2001 02:22:50 +0000
Subject: AW: [PHP-DB] SQL Select statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6708@lists.php.net to get a copy of this message
try something like: select a.memberID from table a, table b where a.choice=2 and b.choice=3 and a.memberID = b.memberID; or select memberID, count(*) from table where choice=2 or choice=3 group by memberID having count(*) = 2; (i don't know what is more effizient, might depend on your indexes and the amount. the second sql asumes you only have one row per memberID - choice (noone should choose 3 2times ore more) mk -----Ursprungliche Nachricht----- Von: bill [mailto:bill@billtron.com] Gesendet: Samstag, 17. Februar 2001 02:45 An: php-db@lists.php.net Betreff: [PHP-DB] SQL Select statement I have a table with three simple columns: id(unique), memberID, and choice I want to find out which memberIDs have BOTH choice 2 AND choice 3. --> SELECT memberID from table where choice=2 AND choice = 3 That won't work (0 results, of course, because no row has two choices, they're mutually exclusive) ---> SELECT memberID from table where choice=2 OR choice = 3 That doesn't work (shows all memberIDs that chose either 2 or 3). Can I maybe join the table upon itself on the memberID? Other suggestions? thanks, bill hollett -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#6708) next »