Answer the question
In order to leave comments, you need to log in
How to specify WHERE correctly if we do LEFT JOIN?
I recently started learning MySQL, so don't be too harsh.
There are 3 databases, one with names and IDs (users), the second one for joining multiple selections (group_type), the third c with types and IDs (types). How to create a correct RIGHT JOIN between tables to indicate that the table will WHERE on id user (that is, select a separate user).
Code example:
SELECT u.*, t.type_name, t.description FROM users AS u WHERE id = 1
LEFT JOIN type_user AS tu ON tu.id_user = u.id
LEFT JOIN types AS t ON tu.id_type = t.id AND;
Answer the question
In order to leave comments, you need to log in
The order of the slander in the query is clearly defined in the documentation , and does not imply any changes or permutations (the exception is the INTO slander when placing the result in a variable for which 3 different locations are described).
SELECT u.*, t.type_name, t.description
FROM users AS u
LEFT JOIN type_user AS tu ON tu.id_user = u.id
LEFT JOIN types AS t ON tu.id_type = t.id
WHERE u.id = 1;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question