simple (I hope) SQL question

Posted on 2014-11-04
Last Modified: 2014-11-06
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. are NOT present on the second table (i.e. are NOT in

thanks a lot for your help,
Question by:fabianope65
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 =
LVL 58

Accepted Solution

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

Open in new window

LVL 11

Assisted Solution

John_Vidmar earned 167 total points
ID: 40422835
FROM	table1	a
JOIN	table2	b	ON =

Open in new window


Author Closing Comment

ID: 40425684
Thanks to all of You,
See You,

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help With Database JOIN 7 28
SSRS 2013 - Creating a summarized report 19 35
SQL Error - Query 6 26
Setting Macro in Access to Automate Running an Append at a Certain Time 2 24
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

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