Click here to Skip to main content
15,891,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got error like this

'
SQL
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

'

while executing this query

SQL
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
Posted
Updated 23-Jul-15 21:28pm
v2

YOu're trying to fetch two values for a single column.
SQL
(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.
 
Share this answer
 
This query

SQL
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

SQL
select TOP 1 DOC_NO from SN where DOC_TYPE='INV' and SN_NO='grn1234'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900