2011-10-19 167 views
-1

我有一個查詢寫在PostgreSQL的獲取空記錄查詢

select components.* 
    from sg_paycomponents components 
     left outer join tblextempinfo info 
      on info.c_company=components.company 
where components.type ='RECURRING-AMOUNTS' 
    and components.cid not in (
           select components 
           from sg_recurringamounts 
           where employee =400 
          ) 
    and info.employee=400; 

此查詢給了我所有的紀錄,但我想,在sg_paycomponents表我應該得到這個紀錄也是在類型=「RECURRING表示的數額」和公司是空我的查詢不給我,如果公司爲null,可以在任何一個plz幫助

回答

3

變化:

and info.employee=400 

要:

and (info.employee=400 OR info.employee IS NULL)