Solved

MySQL - Identifying records on one table but not on another

Posted on 2009-07-02
3
437 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 143

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

837 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