CBSE Class 12 Informatics Practices Question 80 of 90

Querying Using SQL — Question 20

Back to all questions
20
Question

Question 20

Below are the customer and order tables :

Customers

customer id (PK)
first_name
last_name
email
address
city
state
zip

Orders

order id (PK)
order_date
amount
customer_id (FK)

List all customers (name) who have orders (use EXISTS).

Answer
SELECT first_name, last_name
FROM Customers c
WHERE EXISTS (
    SELECT first_name, last_name
    FROM Orders o
    WHERE o.customer_id = c.customer_id
);