I am using SQL Server 2014
and I have a simple T-SQL
query (shown below) with its corresponding output.
use mydatabase
select *
from Table1
where ID in (101, 102, 103)
Output is as follows (meaning ID 102 does not exist in Table1):
ID Age
101 46
103 50
I want the output to be as follows:
ID Age
101 46
102 0
103 50
When there is no match for an ID in the look-up table, the output omits those IDs. How do I change my T-SQL
query to ensure that unmatched IDs are also output but with zeroes.