I need to get a list of identifiers and the corresponding field from a table where the identifier may not exist. For example, a table looks like this:
id | status ------------- 1234 | A 4567 | B 1020 | C
I want to get the status from the lines with id=4567 and id=7777 , for example:
Result: id | status ------------- 4567 | B 7777 |
Since there is no entry with id = 7777, it should show an empty status field.
What I still have: I can get an empty string when there is no record for any match of identifiers, appending the result using DUAL . For instance:
SELECT id, status FROM DUAL LEFT OUTER JOIN mytable ON id='7777'
Gives the result of an empty string:
id | status ------------- |
But adding a valid id to the condition returns only one line:
SELECT id, status FROM mytable WHERE (id='7777' OR id='4567') id | status
How can I make a request return a string with the requested ID, even if it has no record?
source share