SQL Join - 3 tables

Posted on 2009-04-30
Last Modified: 2012-05-06

I have a complicated SQL request to do (for me, a request with a join is always complicated..).

Here are the tables :

id_queue (PK)

id_user (PK)

Agent Member

I want to select all users (firstname, lastname) that don't belong to a "selected" queue.

Is this clear ? Don't hesitate to ask me questions about that. Can you help me with this SQL request ?

Thanks in advance :-)
Question by:chuchyyy
    LVL 142

    Accepted Solution

    with XXX being the selected queue:
    select u.*
      from user u
     where not exists ( select null from agent_member am where am.id_user = u.id_user and am.id_queue = XXX )

    Open in new window

    LVL 2

    Author Closing Comment

    Great ! Thank you Angellll

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    How to script out data export 36 54
    Using TSQL to Return Column Data as Rows 3 33
    Oracle Pivot 2 20
    Pl/SQL Query 31 38
    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…
    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 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

    25 Experts available now in Live!

    Get 1:1 Help Now