?
Solved

MySQL - Identifying records on one table but not on another

Posted on 2009-07-02
3
Medium Priority
?
441 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 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 93

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 1000 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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

777 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