I have three tables. Skills(id), Users(id) and user_skills(user_id, skill_id).
Now, i try a left outer join like :
select * from skills left outer join user_skills ON skills.id = user_skills.skill_id;
But it will not bring back what i need, because there is not check of the user id.
If i do a :
select * from skills left outer join user_skills ON skills.id = user_skills.skill_id where user_skills.user_id = 986759322;
I get back one record, based on the particular user id.
However, I want to get back all skills of a certain user whether the user has that skill discovered or not. So, if the skills are 4, i want back 4 rows that include skill information as well as user information IF user has that skill. If not, this information will be null, but all the skill information will be there.
How can i make such a query ?
Notice that the filtering by user ID is made in the
ONclause and not in theWHERE. That guarantees that you get the skills for that specific user plus the skills he doesn’t have yet.