我收到错误'当EXISTS没有引入子查询时,只能在选择列表中指定一个表达式。 [英] I got error 'Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.'
问题描述
我收到这样的错误
'
只能指定一个表达式 in 选择列表当子查询 不引入 EXISTS 。
'
执行此查询时
选择 PRODUCT_NO,DOC_NO,(选择 INV_DATE as INV_DATE,AC_NAME as AC_NAME 来自 invINVOICE 其中 INV_NO =(选择 DOC_NO 来自 SN 其中 DOC_TYPE = ' INV' 和 SN_NO = ' grn1234')),STATUS,ITEM2 来自 SN 其中 DOC_TYPE = ' INV' 和 SN_NO = ' grn1234'
你能解决这个问题
你想尝试为一个列提取两个值。
(选择 INV_DATE as INV_DATE,AC_NAME as AC_NAME 来自 invINVOICE ...
对于单个列只有一个可以获取值,因此要么删除另一列,要么将其分成两个单独的列。
此查询
选择 DOC_NO 来自 SN 其中 DOC_TYPE = ' < span class =code-string> INV' 和 SN_NO = ' grn1234'
返回多行,所以当你说
WHERE INV_NO =(....)
它无法将INV_NO与多个东西进行比较,一个子查询只能返回一个项目。或者问题可能是您的外部子查询返回多行。我们无法访问您的数据,因此我们不知道您需要测试哪些数据。我们也不知道你的逻辑,所以我们不能告诉你修复是什么。您需要修复数据以使这些子查询是唯一的,或者如果子查询返回多行但值相同,则可以添加TOP 1以将数据减少到一行
选择 TOP 1 DOC_NO 来自 SN 其中 DOC_TYPE = ' INV' 和 SN_NO = ' grn1234'
I got error like this
'Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
'
while executing this query
select PRODUCT_NO,DOC_NO,(select INV_DATE as INV_DATE,AC_NAME as AC_NAME from invINVOICE where INV_NO= (select DOC_NO from SN where DOC_TYPE='INV' and SN_NO='grn1234')),STATUS,ITEM2 from SN where DOC_TYPE='INV' and SN_NO='grn1234'
can you pls solve this解决方案YOu're trying to fetch two values for a single column.
(select INV_DATE as INV_DATE,AC_NAME as AC_NAME from invINVOICE ...
For a single column only a single value can be fetched so either remove the other column or break this to two separate columns.
This query
select DOC_NO from SN where DOC_TYPE='INV' and SN_NO='grn1234'
is returning more than one row, so when you say
WHERE INV_NO = (....)
it can't compare INV_NO to multiple things, a sub query can only return one item. Or the issue could be that your outer sub-query is returning more than one row. We can't access your data so we don't know which, you'll need to test. We don't know your logic either so we can't tell you what the fix is. You either need to fix your data so that these sub-queries are unique, or if the subquery is returning more than one row but the values are the same you can add TOP 1 to reduce the data to one row
select TOP 1 DOC_NO from SN where DOC_TYPE='INV' and SN_NO='grn1234'
这篇关于我收到错误'当EXISTS没有引入子查询时,只能在选择列表中指定一个表达式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!