Answer the question
In order to leave comments, you need to log in
How to replace table id with names from other table?
There is a table logs (id, product_id, count, user_id, status)
How to organize a query to replace product_id with names from the products(id, name) table, and user_id with names from the user(id, name) table?
Answer the question
In order to leave comments, you need to log in
SELECT products.name AS product_name, user.name AS user_name
FROM logs
LEFT JOIN products ON products.id = logs.product_id
LEFT JOIN user ON user.id = logs.user_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question