Skip to content
Advertisement

SQL – Join two queries and also set a default value when there is no match

Is it possible to merge the following two queries and also have a default value offline for status when it doesn’t have entry to match?

Example:

Second query:

Note: when the status is not equal to 1, there is no entry for that in table2. So in table two we have only entries that are online.

I want the final output to be something like

Advertisement

Answer

Yes, this is possible, by doing a FULL OUTER JOIN.

I also assume you want to JOIN on the Objects column:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement