子查询不起作用 [英] Subquery is not working

查看:108
本文介绍了子查询不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建程序[dbo]。[prc_PLC_getDealContactPerson]

@DealID bigint

作为

开始



从PLC_ClientContactPerson中选择*,其中PLC_ClientContactPersonID(从PLC_DealCOntact中选择PLC_ClientCotnactPersonId,其中PLC_DealID = @ DealID);

END



我尝试了什么:



我正在尝试运行此程序,但它给了我error.i'm新的sql请更正错误

解决方案

您缺少IN子句。



从PLC_ClientContactPerson中选择*,其中PLC_ClientContactPersonID IN (从PLC_DealCOntact选择PLC_ClientCotnactPersonId,其中PLC_DealID = @ DealID);



您还可以使用



从PLC_ClientContactPerson中选择* a,

(从PLC_DealCOntact中选择PLC_ClientCotnactPersonId,其中PLC_DealID = @ DealID)b

其中a.PLC_ClientContactPersonID = b.PLC _ClientContactPersonID

Create Procedure [dbo].[prc_PLC_getDealContactPerson]
@DealID bigint
As
Begin

select * from PLC_ClientContactPerson where PLC_ClientContactPersonID (select PLC_ClientCotnactPersonId from PLC_DealCOntact where PLC_DealID=@DealID);
END

What I have tried:

i'm trying to run this procedure but its giving me error.i'm new to sql please correct error

解决方案

You are missing the IN clause.

select * from PLC_ClientContactPerson where PLC_ClientContactPersonID IN (select PLC_ClientCotnactPersonId from PLC_DealCOntact where PLC_DealID=@DealID);

You can also use

select * from PLC_ClientContactPerson a,
(select PLC_ClientCotnactPersonId from PLC_DealCOntact where PLC_DealID=@DealID) b
where a.PLC_ClientContactPersonID = b.PLC_ClientContactPersonID


这篇关于子查询不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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