Solved

MySQL - Identifying records on one table but not on another

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Read about achieving the basic levels of HRIS security in the workplace.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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 …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now