in Databases edited by
1,862 views
3 votes
3 votes

Tables are : COUNTRY (CODE, NAME) and MEMBER (ORGANIZATION, COUNTRY_code). primary keys are in blod letters and foreign key is in italics.

SELECT COUNTRY.name
FROM
COUNTRY
JOIN member
ON
COUNTRY.code= member.COUNTRY_code
WHERE member.ORGANIZATION =ALL(SELECT organization
FROM member
WHERE
member.
COUNTRY_code=COUNTRY.code )


What wil be the output of given SQL query?

1. List the names of countries which are members of at least one organisation.

2. List the names of countries which are members of only one organisation.

3. List the names of countries which are members of one or more organisations.

4. List the names of countries which are members of all  organisations.

in Databases edited by
by
1.9k views

2 Answers

2 votes
2 votes
bro I think answer is B) only one org will be equal to inner sub query.

2 Comments

corrrect...

How to solve this? Exactly how ALL command works?Any useful link??
0
0
bro @sh!va take an example of 2 tables and run above query you will find that only one organization must exist in member to solve the given query correct o/p country names
0
0
0 votes
0 votes

Answer is B because if the inner subquery return more than one value than the organization won’t be the primary key and ALL is evaluated to be true when it matches all the values inside the inner query 

https://oracle-base.com/articles/misc/all-any-some-comparison-conditions-in-sql

Related questions