Answer the question
In order to leave comments, you need to log in
How to make a sample?
Hello. I had such task:
There is a table users:
id | fio | val1 | val2 | val3 |
----------------------------------------------------- |
0 | ivanov | 0 | 1 | 3 |
------------------------------------------------
In the fields val id values from another table values:
id | values |
----------------------
0 100
1 200
2 300
---------------------- -
What query do you need to execute so that you return the first table with the values from the second?
Answer the question
In order to leave comments, you need to log in
Attention pseudocode
SELECT `id`, `fio`, `v1`.`values` AS `val1`, `v2`.`values` AS `val2`, `v3`.`values` AS `val3`
FROM `users` AS `u`
JOIN `values` AS `v1` ON `u`.`val1` = `v1`.`id`
JOIN `values` AS `v2` ON `u`.`val2` = `v2`.`id`
JOIN `values` AS `v3` ON `u`.`val3` = `v3`.`id`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question