Getting Database values and deducting

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
TheDodo
Forum Newbie
Posts: 1
Joined: Sun Nov 24, 2013 12:02 pm

Getting Database values and deducting

Post by TheDodo »

Hello people, I've 1 database with 2 tables, the first one has IDs of the a person, the name of this person. The second one also has the ID of the person and the name, but the second one might not have all names or IDs that are stored in the table nr1. What I would like to do, is: get the IDs/names of the one that are not in the table 2.
Thanks.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Getting Database values and deducting

Post by requinix »

Take the first table with the complete data and LEFT JOIN it with the second table. Then restrict the results to where the ID in the second table is NULL (which would happen when there was no match against the first table).
Post Reply