Nested Selects and Results Needed


Trying to help a friend while I learn SQL

Need to get result set that will EXCLUDE rows from the first query---if they also occur in the second query..

Unsure which is considered the first query.  Nested?  as the First Executed?  
OR, is the 1st listed?

Intersect is out, as that would give me entries in BOTH tables
I think a Minus is just the opposite.... Excluding entries from the 2nd, and adding unique ones

I came up with either of the following....

Select CLastName
From tblClients
EXCEPT
Select PLastName
From tblPeople
Order by CLastName

OR could I use

Select CLastName From tblClients
UNION MINUS
Select PLastName From tblPeople
Order by CLastName


Kind of stranded here!
LVL 5
Bob BenderAsked:
Who is Participating?
 
jogosConnect With a Mentor Commented:
Except will do.

Lastname doesn't seem that unique to me I hope this is only a simplified example.
0
 
Bob BenderAuthor Commented:

Followup for completeness...

Unsure which is considered the first query.  The Nested one?  OR, is it the 1st listed?

The C and P add the clarity,  but I didn;t write the names, they were supplied by my friend, so simplified is prolly his way of life!
0
 
jogosCommented:
read it like this

select this
except
select notinthis
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.