在仓库tab1中有一个列c1的表。还创建了另一个表tab2和列c2。我想知道c2 details是否已经在tab1中了。C1并在新列中显示yes或no。有人知道如何使用sql吗?
这是我使用的一个粗略的方法
SELECT
t2.id,
CASE WHEN t1.id IS NULL THEN 'NO' ELSE 'YES' END AS DataExists
FROM tab2 t2
--if c2 doesnt exist in the t1 this join will be null
LEFT JOIN tab1 t1 on t1.c1 = t2.c2