SQL连接和where子句有疑问 [英] SQL join and where clause doubt

查看:65
本文介绍了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

推荐答案



你可以使用左连接查询。它可以帮助你,


you can use left join query. it may help you,
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


您好,



尝试<$ c对于T_Allocation表,$ c> OUTER JOIN 。

Hi,

try with OUTER JOIN for T_Allocation table.
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链接链接



SQL SERVE R - JOIN简介 - JOIN的基础 [ ^ ]



SQL Server加入示例 [ ^ ]



不同类型的SQL连接 [ ^ ]



SQL SERVER JOINs [ ^ ]



Rega rds,

GVPrabu
Hi,

Refer the following Links for SQL JOIN

SQL SERVER – Introduction to JOINs – Basic of JOINs[^]

SQL Server Join Example[^]

Different Types of SQL Joins[^]

SQL SERVER JOINs[^]

Regards,
GVPrabu


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆