Thank you very much Lachlan and SpamVortex!  I appreciate the help!

Jonathan
 
 
>>>[EMAIL PROTECTED] 07/07 6:59 pm >>> 
You can do it one of two ways..  Either you can do a 
"self join" like the following: 
 
select t1.userid 
from answers t1, 
     answers t2 
where t1.qid = 5 
 and lower(t1.answer)='student' 
 and t2.qid = 6 
 and lower(t2.answer) like 'edu%' 
 and t1.userid = t2.userid 
 
or you can use a union (available in 4.0.0 or greater) 
 
select userid 
 from answers 
where qid = 5 and lower(answer) = 'student' 
UNION 
select userid 
 from answers 
where qid = 6 and lower(answer) like 'edu%' 
 
union automatically does a distinct so you will get 
one row back for each user that answered that they are 
education students. 
 
 
--- Jonathan Duncan <[EMAIL PROTECTED]> wrote: 
>I am trying to figure out what my select statement 
>should be to combine 
>both of these into one: 
> 
>SELECT userid FROM Answers WHERE answer like 
>"Education%"; 
>SELECT userid FROM Answers WHERE answer="Student"; 
> 
>Table Answers looks like: 
>-id int 
>-userid int 
>-answer text 
> 
>for each row there would be something like: 
>+-----+--------+----------+ 
>| qid | userid | answer   | 
>+-----+--------+----------+ 
>|  5  |   3000 | Student  | 
>+-----+--------+----------+ 
> 
>There are often multiple asnwers for each question. 
> 
>I want to select the userid's from the table where 
>people answered 
>"Student" in question 5 and "Education" in question 
>6. 
> 
>I am using MySQL 4.08 so I can't do the subquery 
>thing. 
> 
>Thanks, 
>Jonathan Duncan 
> 
>-- 
>MySQL General Mailing List 
>For list archives: http://lists.mysql.com/mysql 
>To unsubscribe:   
> 
http://lists.mysql.com/[EMAIL PROTECTED] 
> 
> 
 
 
-- 
MySQL General Mailing List 
For list archives: http://lists.mysql.com/mysql 
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to