Try this way :
"select t1.memberID,t1.choice,t2.memberID, t2.choice from table as t1, table
as t2 where t1.choice = 2 and t2.choice =3"
It works, but you'll going to have as many records as the bigger number of
records between choice=2 and choice = 3, no matter you use the distinct
keyword or not. I
think you can give your problem another approach, splitting it in two
queries and joining the result sets through php script.
Sometimes you can't put SQL to do all the work.
HTH
Jayme.
-----Mensagem Original-----
De: bill <[EMAIL PROTECTED]>
Para: <[EMAIL PROTECTED]>
Enviada em: sexta-feira, 16 de fevereiro de 2001 22:44
Assunto: [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]