TABLE T1
Name | ID |
---|---|
AMAN | 10 |
JIM | 11 |
SAM | 12 |
TABLE T2
VAL | ID |
---|---|
A00 | 10 |
B0 | 11 |
The result I want:
T3
Name | ID | VAL |
---|---|---|
AMAN | 10 | A00 |
JIM | 11 | B0 |
SAM | 12 | NA |
How can I write this query?
Advertisement
Answer
SELECT t1.name, t1.id, coalesce(t2.val,'n/a') FROM t1 LEFT JOIN t2 ON t1.id = t2.id