I have craftsmanships table which has (id, name) and users table (id, email, ..). When a user has some craftsmanships,
theyare stored inside the contractor_skills(user_id, craftsmanship_id, id) table.
What I want here is that to list all the available craftsmanships with id, name and has column. I can get now only
thosecraftsmanships that a specific user has,
SELECT
craftsmanships.id,
craftsmanships.name,
TRUE as has
FROM
"craftsmanships"
INNER JOIN "contractor_skills" ON "contractor_skills"."craftsmanship_id" = "craftsmanships"."id"
INNER JOIN "users" ON "users"."id" = "contractor_skills"."user_id"
WHERE (contractor_skills.user_id = 8)
ORDER BY
"craftsmanships".”id"
——————
id | name | has
----+---------+-----
1 | paint | t
2 | drywall | t
(2 rows)
But I want to list all craftsmanships and has column should have `t` when user_id #8 has it, else `f`. How can I extend
this query?
Thanks,
Arup Rakshit
ar@zeit.io