Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Optional column in SELECT statement

I would like to add the following column to a SELECT statement:

input_channel from device_serial JOIN device_serial.device_id = expression.shoe_id JOIN indicator.enum = expression.channel.

If no such value is found, I would like the corresponding entry in the column to be NULL.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

At the moment I only have

SELECT i.type, i.function, i.enum FROM indicator i; 

I believe this would require a LEFT OUTER JOIN, but a bit confused about how to incorporate the expression join. I do not need any values from the expression table I am just using it to locate the correct value for input_channel in device_serial.

>Solution :

You don’t have to select a column from the table, you can still use it:

SELECT i.type, i.function, i.enum, ds.input_channel
FROM indicator i
LEFT OUTER JOIN expression e ON e.channel = i.enum
LEFT OUTER JOIN device_serial ds ON ds.device_id = e.shoe_id;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading