Sql join显示空值

时间:2013-12-06 11:00:35

标签: sql sql-server left-join inner-join

我有2个sql表mtblSite_Lavel_Budget和mtblExpenditure_Site_Lavel。我想加入它们,所以我在下面编写了查询,但是一列总是给出null结果,尽管该字段中有值。

enter image description here

enter image description here

查询如下

select mtblExpenditure_Site_Lavel.SFTI_Id, 
mtblExpenditure_Site_Lavel.Site_Lavel_Interventions, 
mtblExpenditure_Site_Lavel.Sub_Site_Lavel_Interventions,
mtblExpenditure_Site_Lavel.Bill_No, mtblExpenditure_Site_Lavel.Date_Of_Bill,
mtblExpenditure_Site_Lavel.Eligible_Exp,
mtblExpenditure_Site_Lavel.Non_Eligible_Exp,
mtblExpenditure_Site_Lavel.Total,
mtblExpenditure_Site_Lavel.Physical_Progress,
mtblSite_Lavel_Budget.Sanction_Amount_DPR  
from mtblExpenditure_Site_Lavel 
left join mtblSite_Lavel_Budget 
   on mtblExpenditure_Site_Lavel.Sub_Site_Lavel_Interventions= mtblSite_Lavel_Budget.Sub_Site_Lavel_Interventions 
WHERE mtblExpenditure_Site_Lavel.SFTI_Id =13 
ORDER BY Date_Of_Bill desc

,结果如下

enter image description here

请就此问题提出建议。

1 个答案:

答案 0 :(得分:0)

试试这个

   from mtblExpenditure_Site_Lavel left join  mtblSite_Lavel_Budget on 
       mtblExpenditure_Site_Lavel.sfti_id = mtblSite_Lavel_Budget.sfti_id 

我认为它很混乱,因为你加入了一个字符串列,它最好尽可能加入id。