Reputation: 628
This query works fine:
SELECT country_name FROM countries WHERE country_id IN (23,86,79)
so I can get the list of countries' name based on those country_id. But what I want is to get them with a subquery like:
SELECT country_name FROM countries WHERE country_id IN (SELECT office_id FROM countries WHERE country_code='FRA')
I can get the first name of the office Id and not all (in this case should be 4). The office_id and country_id are Int. Any helps?
Upvotes: 0
Views: 44
Reputation: 77926
why do you need such wrong/long turn query. your posted query (below) with subquery
SELECT country_name
FROM countries
WHERE country_id IN ( SELECT office_id
FROM countries
WHERE country_code='FRA' )
Can be simpliy
SELECT country_name
FROM countries
WHERE country_code='FRA';
Upvotes: 2