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:[EMAIL PROTECTED]]
Gesendet: Samstag, 17. Februar 2001 02:45
An: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]