• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

SQL Join - 3 tables

Hello,

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

Here are the tables :

Queue
id_queue (PK)
name

User
id_user (PK)
firstname
lastname
etc...

Agent Member
id_agent_member
id_user
id_queue

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 :-)
0
chuchyyy
Asked:
chuchyyy
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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

0
 
chuchyyyAuthor Commented:
Great ! Thank you Angellll
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now