Answer the question
In order to leave comments, you need to log in
How, depending on the value of the author's type attribute, to select a name from different tables (WHEN, CASE)?
There is a view in which I display the id, the author's name and the text of the message.
In the table with messages, I entered the author's id and author's type attributes.
How to get name values from different tables depending on the different type of author.
SELECT
messages.id
messages.text
case messages.typeauthor
when '1'
when '2'
FROM messages
messages.authorid
SELECT idmc.name
FROM idmc
WHERE idmc.id = messages.authorid
SELECT suppliers.name
FROM suppliers
WHERE suppliers.id = messages.authorid
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question