0

結合された行に追加情報を追加するにはどうすればよいですか?

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

あなたの助けをどうもありがとう!

4

2 に答える 2

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 
于 2012-04-06T16:08:53.687 に答える
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 
于 2012-04-06T16:09:31.427 に答える