Could you please let me know how to left join two different tables based on the condition? I appreciate any help.
SELECT A.id,
A.flag,
B.fname,
B.lname
FROM Table1 A
CASE
WHEN ISNULL(A.flag, 0) = 0 THEN LEFT
JOIN Table2 B
ON B.id = A.id
ELSE
LEFT JOIN Table3 B
ON B.id = A.id
Try this: