Solved

SQL question

Posted on 2014-11-11
3
183 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 73

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

772 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