How to structure this query...?
Posted
by SpikETidE
on Stack Overflow
See other posts from Stack Overflow
or by SpikETidE
Published on 2010-03-24T10:28:05Z
Indexed on
2010/03/24
10:33 UTC
Read the original article
Hit count: 240
mysql-query
Hi Everyone...
Consider the following table....
hotel facilities
1 internet
1 swimming pool
1 wi-fi
1 parking
2 swimming pool
2 sauna
2 parking
3 toilets
3 bungee-jumping
3 internet
4 parking
4 swimming pool
I need to select only the hotels that have parking, swimming pool and internet....?
I worked out the following....
SELECT hotel
FROM table
WHERE facilties IN(internet, swimming pool, parking)
This query selects the hotels that has atleast one among the choices.
But what i need is a query that selects the hotels that has ALL of the selected facilities...
Thanks for your suggestions....
© Stack Overflow or respective owner