查询中获取空记录

发布于 2024-12-10 14:25:14 字数 610 浏览 0 评论 0原文

我在 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 表中我也应该得到该记录,其中 type = 'RECURRING-AMOUNTS' 且公司为空,如果公司为空,我的查询不会给我任何记录一位请帮忙

I have one query written in 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;

this query giving me all record but i want that in sg_paycomponents table i should get that record also where type = 'RECURRING-AMOUNTS' and company is null my query is not giving me if company is null can any one plz help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情妓 2024-12-17 14:25:14

更改:

and info.employee=400 

至:

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

Change:

and info.employee=400 

To:

and (info.employee=400 OR info.employee IS NULL)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文