Answer the question
In order to leave comments, you need to log in
How to make a selection from three tables?
How to make a selection from three tables linked by one table?
I write something like this but it doesn't work
SELECT game.id,npc.title,users.login FROM game INNER JOIN npc ON game.id = npc.npc_id AND game.type = 'npc' INNER JOIN users ON game.id = users.user_id AND game.type = 'user'
Answer the question
In order to leave comments, you need to log in
SELECT game.id,npc.title,users.login
FROM game
LEFT JOIN npc ON game.id = npc.npc_id AND game.type = 'npc'
LEFT JOIN users ON game.id = users.user_id AND game.type = 'user'
WHERE game.type IN('npc' , 'user')
если я правильно понял картинку, то вам нужно использовать UNION
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question