找到银行中拥有账户但不是银行贷款的所有客户

时间:2018-03-27 06:17:04

标签: mysql sql database

我有一些表格:

"branch" table(branch_name, branch_city, assets)
"customer" table(customer_name, customer_street, customer_city)
"account" table (account_number, branch_name, balance)
"loan"table (loan_number, branch_name, amount)
"depositor"table (customer_name, account_number)
"borrower" table (customer_name, loan_number)

现在我想找到所有有帐户但没有贷款的客户 我试过

SELECT customer_name 
FROM depositor 
MINUS 
SELECT customer_name 
FROM borrower

但它显示错误1064

1 个答案:

答案 0 :(得分:0)

我得到了答案

SELECT DISTINCT customer_name FROM depositor WHERE customer_name NOT IN(SELECT customer_name FROM borrower);