Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL query, find the user that does not have bank_account

SQL query, find the user that does not have bank_account

I have two tables, the first one is table bank_customer, and the other is table user.
The table of bank_customer has many columns, including user_id and bank_account.
in table user, I have column id.

not every user has bank_account. so I want to query, users that do not have a bank_account, but it gets hard.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

SELECT * FROM users, bank_customers
WHERE NOT users.id=bank_customers.user_id

so how can I query in SQL with this case?

and how to logic that case? for the next case I can find out by myself.

>Solution :

There are a few ways to go about that, but the simplest way would probably be using IN:

SELECT *
FROM users
WHERE id NOT IN (
    SELECT user_id
    FROM bank_customers
)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading