Jonathan,
I'm going to assume you want to match the answer fields in the way those 2
query examples do and that the qid field refers to the Question number.
SELECT
userid
FROM
Answers a1 JOIN Answers a2 ON
a1.userid = a2.userid
WHERE
a1.qid = 5 AND
a1.answer = 'Student' AND
a2.qid = 6 AND
a2.answer LIKE 'Education%';
The above joins the table back to another copy of itself by userid. This
allows you to find the students that answered both questions correctly. Give
it a go.
cheers
Lachlan
-----Original Message-----
From: Jonathan Duncan [mailto:[EMAIL PROTECTED]
Sent: Thursday, 8 July 2004 10:04 AM
To: [EMAIL PROTECTED]
Subject: selecting rows that match two criteria
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]