如何向已加入的行添加其他信息?
SELECT column1, column2
FROM table1
LEFT JOIN table2
ON column1 = col1_table2 //The row which matches with this join should have additional information e.g. "'joined' AS info
非常感谢你的帮助!
答案 0 :(得分:2)
如果我理解你的问题,这应该有效:
SELECT
t1.column1,
t1.column2,
CASE WHEN t2.col1_table2 IS NOT NULL THEN 'joined' END AS info
FROM table1 t1
LEFT JOIN table2 t2 ON t1.column1 = t2.col1_table2
答案 1 :(得分:2)
试试这个:
SELECT column1,
column2,
CASE WHEN col1_table2 IS NOT NULL THEN 'joined' END AS additional_field
FROM table1
LEFT JOIN table2 ON column1 = col1_table2