本文介绍了SQL连接和where子句有疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ALTER PROC [dbo].[GET_PDFEXPORT](@ENT_NUM as varchar(10))
as
select a.Enterprise_number,a.Name,b.Report_Type as Report,b.Red_Flag as FileType, c.Link as SEC_LINK from T_CompanyFinancial a
join T_Tracking b on a.Enterprise_number=b.Enterprise_number
join T_Allocation c on a.Enterprise_number=c.Enterprise_Number
where a.Enterprise_number=@ENT_NUM





您好以上查询我有以下疑问



我需要来自t_allocation表的链接所以需要在这里使用join

但同时来自T_CompanyFinancial的所有Enterprise_number未在表T_allocation中显示

如果T_allocation中不存在Enterprise_number则意味着sec_l​​ink可以为空白



HOw可以这样做



帮助我谢谢



hi from above query i have following doubt

I need link from t_allocation table so there is need to use join here
but same time all the Enterprise_number from T_CompanyFinancial not presented in table T_allocation
if Enterprise_number is not present in T_allocation means sec_link can be blank

HOw can do this

Help me thanks

推荐答案

SELECT a.Enterprise_number,a.Name,b.Report_Type as Report,b.Red_Flag as FileType, c.Link as SEC_LINK
FROM T_CompanyFinancial a
INNER JOIN T_Tracking b on a.Enterprise_number=b.Enterprise_number
LEFT OUTER JOIN T_Allocation c on a.Enterprise_number=c.Enterprise_Number
WHERE a.Enterprise_number=@ENT_NUM





问候,

Prakash.T



regards,
Prakash.T


select a.Enterprise_number,a.Name,b.Report_Type as Report,b.Red_Flag as FileType, c.Link as SEC_LINK from T_CompanyFinancial a
join T_Tracking b on a.Enterprise_number=b.Enterprise_number
LEFT OUTER join T_Allocation c on a.Enterprise_number=c.Enterprise_Number
where a.Enterprise_number=@ENT_NUM





希望有帮助



hope it helps



这篇关于SQL连接和where子句有疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 19:00