Monday, 19 August 2013

How to use IN query?

How to use IN query?

In mp_cities table city_name and city_id are the fields
city_id city
--------------------
1 Chennai
2 Bangalore
3 Kerala
In profile table
user_email city_type
------------------------------
abc@gmail.com 1,2,3
I am using the following query
SELECT city_name
FROM mp_cities
WHERE city_id IN (SELECT city_type
FROM profile
WHERE user_email='abc@gmail.com')
this query will result Chennai. I have to get all the cities

No comments:

Post a Comment