[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Nested Selects and Results Needed

Posted on 2011-10-08
Medium Priority
Last Modified: 2012-05-12

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
Select PLastName
From tblPeople
Order by CLastName

OR could I use

Select CLastName From tblClients
Select PLastName From tblPeople
Order by CLastName

Kind of stranded here!
Question by:Bob Bender
  • 2
LVL 25

Accepted Solution

jogos earned 1000 total points
ID: 36937823
Except will do.

Lastname doesn't seem that unique to me I hope this is only a simplified example.

Author Comment

by:Bob Bender
ID: 36938757

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!
LVL 25

Expert Comment

ID: 36939334
read it like this

select this
select notinthis

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

873 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