Home Issues with understanding multiple joins
Reply: 0

Issues with understanding multiple joins

user810
1#
user810 Published in June 21, 2018, 8:44 am

I have the following tables:

users
 ____________
| id         |
| first_name |
|____________|

pre_task_plans
 ____________
| id         |
| creator_id | (fk user_id)
|____________|

pre_task_plan_users
 __________________
| id               |
| user_id          |
| pre_task_plan_id |
|__________________|

I am trying to get all users for pre_task_plans where I am the creator of (users.id 1)

I have

SELECT users.*
FROM users
JOIN pre_task_plans as ptp on ptp.creator_id = 1
JOIN pre_task_plan_users as ptpu on ptpu.pre_task_plan_id = ptp.id

But it is returning users that are not in pre_task_plan_users related to my pre_task_plans. What am I not understanding about how the 2nd JOIN is working?

PSQL 9.6.2

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.481314 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO