• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • 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)
name
etc...

Agent Member
id_agent_member
id_user
id_queue

I want to select for each queue name, all the users who belong to this queue. A user may belong to several queues.

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
  • 2
1 Solution
 
allmerCommented:
SELECT q.Name, u.name
FROM
    Queue q INNER JOIN AgentMember am ON q.id_queue=am.id_queue
    INNER JOIN User u ON u.id_user=am.id_user

Does this answer the problem?
0
 
chuchyyyAuthor Commented:
Yes, thanks. After modification to fit with my database :

SELECT q.Name, u.firstname, u.lastname
FROM
    queue q INNER JOIN agent_member am ON q.id_queue=am.id_queue
    INNER JOIN user u ON u.id_user=am.id_user
0
 
chuchyyyAuthor Commented:
Thanks mate ! :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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