Strange SQL problem selecting multiple values for same column
- by Nubber
Hello there,
Been at this for a few hours now and I can't make any sense of it. I've used this way of selecting multiple values for same column a few times, but there is something weird with this one.
SELECT * FROM employee as s
INNER JOIN works AS w1 ON w1.name = s.name
INNER JOIN employee AS w2 ON w2.name = s.name
INNER JOIN employee AS w3 ON w3.name = s.name
WHERE w2.city = 'Washington'
Basically what I want to do is find all companies which have people in all the cities. The company name is under 'works'. The problem is however that if I have the WHERE w2.city='Washington' it will make ALL the cities match Washington when it should only touch w2 and leave w3 alone so I could match it with another value.
Anyone know why its doing this? Or know a better way to do it.
Thank you very much in advance.