Click here to Skip to main content
15,886,810 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have multiple value


But have error my code

Please help

 I have error in second line please help
 
Msg 116, Level 16, State 1, Line 3
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. 


What I have tried:

SELECT * FROM DBO.mp_racun_roba  WHERE id_fakture=(select * from mp_racun_lista where datum=CONVERT(date,GETDATE()))  
Posted
Updated 19-Nov-19 0:21am
v2

The subquery must return only one value, you can use TOP for this: SQL SELECT TOP, LIMIT, ROWNUM[^]
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 19-Nov-19 9:43am    
5ed. A good alternative if OP needs to use a single value as a comparison.
Your inner SELECT query is returning more than one value - so SQL rightly complains that it can't test multiple values against a column with an equality test.

If you are trying to get a specific row which matches one ID value, then you need to refine the inner query until it will only ever return a single value.

If you are trying to return multiple rows with different ID values for the same data, then use IN instead of an equality test:
SQL
SELECT * FROM DBO.mp_racun_roba WHERE id_fakture IN (SELECT IDColumnName FROM mp_racun_lista WHERE datum=CONVERT(date,GETDATE()))
 
Share this answer
 
Comments
Goran Bibic 19-Nov-19 6:33am    
Thank you
OriginalGriff 19-Nov-19 6:39am    
You're welcome!

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