Solved

simple (I hope) SQL question

Posted on 2014-11-04
4
145 Views
Last Modified: 2014-11-06
hello,
just a simple question (I hope).
I've 2 tables (say table1 and table2) both have a common column (say "cf") but the first table has in this column more values than the second (aka the first table have more records than the second).
I'd like to extract all the data of the first table whose cf values (i.e. table1.cf) are NOT present on the second table (i.e. are NOT in table2.cf)

thanks a lot for your help,
fabiano
0
Comment
Question by:fabianope65
[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
4 Comments
 
LVL 26

Assisted Solution

by:Shaun Kline
Shaun Kline earned 167 total points
ID: 40422154
select *
from table1
where not exists (select 1 from table2 where cf = table1.cf)
0
 
LVL 58

Accepted Solution

by:
Gary earned 166 total points
ID: 40422156
SELECT * FROM table1 WHERE cf NOT IN (SELECT cf FROM table2)

Open in new window

0
 
LVL 11

Assisted Solution

by:John_Vidmar
John_Vidmar earned 167 total points
ID: 40422835
SELECT	*
FROM	table1	a
LEFT
JOIN	table2	b	ON	a.cf = b.cf
WHERE	b.cf IS NULL

Open in new window

0
 

Author Closing Comment

by:fabianope65
ID: 40425684
Thanks to all of You,
See You,
Fabiano
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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