Nested Selects and Results Needed

Posted on 2011-10-08
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
    LVL 25

    Accepted Solution

    Except will do.

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

    Author Comment

    by:Bob Bender

    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

    read it like this

    select this
    select notinthis

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now