Solved

MySQL - Identifying records on one table but not on another

Posted on 2009-07-02
3
436 Views
Last Modified: 2013-12-13
I have two tables that have some columns in common.including a unique identifying key which is shared by both. One table has 'x' rows, the other has 'x-y' rows - I want to be able to construct a query that will show me the rows that are on table 1, but not on table 2 .... is this possible?
0
Comment
Question by:me_patrick
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 24763348
this will do
select t1.*
  from table1 t1
  left join table2 t2
    on t1.key = t2.key
  where t2.key is null

Open in new window

0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 250 total points
ID: 24763360
In SQL Server you would use:

SELECT t1.*
FROM Table1 t1 LEFT JOIN
      Table2 t2 ON t1.ID = t2.ID
WHERE t2.ID IS NULL

The MySQL syntax should be similar...
0
 

Author Closing Comment

by:me_patrick
ID: 31599191
Thanks guys - spot on.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question