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.
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.
CodePudding user response:
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;