Solved

SQL question

Posted on 2014-11-11
3
188 Views
Last Modified: 2014-11-11
I have SQL question I would like some help with.
0
Comment
Question by:mdoland
  • 2
3 Comments
 

Author Comment

by:mdoland
ID: 40436034
Whoops, I missed the question...

I have to tables X and Y. See below.
X with columns A1 and A2.
Y with columns A1 and A3.

I want to have all elements from A1 in table X where there are no corresponding element A1 in Y.
Did that make sense?
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 40436038
select a1 from x
where a1 not in (select a1 from y)


or

select a1 from x
where not exists (select 1 from y where y.a1 = x.a1)


or

select a1 from x
minus
select a2 from y

Note, the minus version will implicitly return distinct values, that may or may not be what you want.
0
 

Author Comment

by:mdoland
ID: 40436079
Perfect!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

679 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