View the Exhibit and examine DEPARTMENTS and the LOCATIONS tables.
Evaluate the following SQL statement:
SELECT location_id, city
FROM locations
l WHERE NOT EXISTS (SELECT location_id
FROM departments
WHERE location_id <> l.location_id);
This statement was written to display LOCATION_ID and CITY where there are no departments located.
Which statement is true regarding the execution and output of the command?
A.
The statement would execute and would return the desired results.
B.
The statement would not execute because the = comparison operator is missing in the WHERE clause of the outer query.
C.
The statement would execute but it will return zero rows because the WHERE clause in the inner query should have the = operator instead of <>.
D.
The statement would not execute because the WHERE clause in the outer query is missing the column name for comparison with the inner query result.
create table jbbb as select distinct job from emp;
SELECT empno
FROM empu l WHERE NOT EXISTS (SELECT job
FROM jbbb WHERE job l.job);
SELECT empno
FROM empu l WHERE EXISTS (SELECT job
FROM jbbb WHERE job l.job);
What kind of store is present in one or more cities?
SELECT DISTINCT store_type FROM stores
WHERE EXISTS (SELECT * FROM cities_stores
WHERE cities_stores.store_type = stores.store_type);
What kind of store is present in no cities?
SELECT DISTINCT store_type FROM stores
WHERE NOT EXISTS (SELECT * FROM cities_stores
WHERE cities_stores.store_type = stores.store_type);