MiniGunnR MiniGunnR - 1 year ago 63
SQL Question

How to do SQL query based on foreign key field?

I have the following tables:


id, name


id, people_id, name

I have tried the following:

SELECT * FROM people
LEFT JOIN parent ON = parent.people_id
WHERE != 'Carol';

How to find all the people whose parent's name is not Carol?

Answer Source

You can try below code

select from people
inner join parent on
where not in ('Carol')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download