
June 15th, 2012, 10:31 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
it doesn't work because the WHERE clause evaluates each row by itself, and the same column value cannot be equal to 4 different things simultaneously
what you're looking for is four different rows
Code:
SELECT person.name
FROM person
INNER
JOIN [order]
ON [order].personid = person.id
AND [order].name IN ('bike','pencil','book','soda')
GROUP
BY person.name
HAVING COUNT(DISTINCT [order].name) = 4
two comments...
first, ORDER is a reserved word, so you have to escape it (better would be to rename the table)
second, strings are delimited by the single quote, not the doublequote

|