Lab 8
1. Find the name of customers who have both saving and checking account types.
SELECT DISTINCT c.cust_name
FROM customer c
WHERE EXISTS (
SELECT 1 FROM customer
WHERE cust_ID = c.cust_ID AND acc_type = 'saving'
) AND EXISTS (
SELECT 1 FROM customer
WHERE cust_ID = c.cust_ID AND acc_type = 'checking'
);
使用exists
来检查同时存在saving和checking两种账户的用户,运行后发现不存在这样的用户: