Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL question

Posted on 2014-11-11
3
Medium Priority
?
216 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

972 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