即使第二个为空,我如何从2个表中显示?

时间:2019-05-14 21:36:59

标签: sql

即使第二个表为空,我如何显示2个表中的数据? 这是我的代码,但是我只有在值不为null的地方!

SELECT ot.term as term1, tt.term as term2 
FROM translation t, original_language ol, original_term ot 
LEFT JOIN translate_term tt ON tt.id = ot.id, translate_language tl 
WHERE t.fk_original_labguage_id = ol.id 
AND ol.id = ot.fk_original_language_id 
AND t.fk_translation_labguage_id = tl.id 
AND tt.fk_translate_language_id = tl.id

2 个答案:

答案 0 :(得分:0)

没有表定义,没人知道您想要什么。我试图转换为JOIN语法。

SELECT ot.term as term1, tt.term as term2 
FROM translation t
JOIN original_language ol ON t.fk_original_labguage_id = ol.id 
JOIN original_term ot ol.id = ot.fk_original_language_id 
LEFT JOIN translate_term tt ON tt.id = ot.id, translate_language tl AND t.fk_translation_labguage_id = tl.id AND tt.fk_translate_language_id = tl.id

答案 1 :(得分:0)

您需要学习使用正确的LEFT JOIN语法。然后ON的条件放在SELECT ot.term as term1, tt.term as term2 FROM translation t JOIN original_language ol ON t.fk_original_labguage_id = ol.id JOIN original_term ot ON ol.id = ot.fk_original_language_id LEFT JOIN translate_term tt ON tt.id = ot.id ; 子句中:

MediaPB_Band_AI_Dia = 
CALCULATE(
    dPBomba_AI_FL[.PBomba_Medio];
    ALLEXCEPT(dPBomba_AI_FL;
        dPBomba_AI_FL[Data Coleta];
        dPBomba_AI_FL[Área de Influência];
        dPBomba_AI_FL[Combustivel];
        dPBomba_AI_FL[Bandeira]
    )
)

我删除了查询中涉及语言的部分,因为您没有选择任何与语言相关的列。