Answer the question
In order to leave comments, you need to log in
What SQL query will allow you to get such a selection?
There is a database of the form:
With data:
Tables PC, Monitor, Printer, respectively, are filled with the values indicated on the last screen.
What SQL query can be used to get such a selection:
Answer the question
In order to leave comments, you need to log in
If the assumption is correct that only one id_* in Task has a non-null value, then something like this (a head-on solution, it can be more elegant)
select value, (case
when id_pc is not null then (select value from PC where id=id_pc )
when id_monitor is not null then (select value from Monitor where id=id_monitor)
when id_printer is not null then (select value from Printer where id=id_printer)
end) as res from Task
order by id;
If the assumption is not true, then just the condition in the case will be more difficult
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question