Solved

simple (I hope) SQL question

Posted on 2014-11-04
4
142 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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