Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all what is the error on below Code:Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

SQL
SELECT ID,firstName FROM human u WHERE fatherID IN(
                                    SELECT  ID,firstName FROM human h WHERE  fatherID IN
                                    (SELECT ID,firstName FROM human u WHERE ID = 2)
                                    )

I NEED A HELP
Posted

Your sub query is returning more than one column. It should be returning only one column. That aside, I do not see a point of using sub query here. Shouldn't this give the result you expect:

SQL
SELECT ID, FIRSTNAME FROM HUMAN WHERE FATHERID=2


You should also try and read guidelines to ask question. Subject should be precise and not entire question itself.
 
Share this answer
 
Comments
m.mongolia 5-Aug-14 11:04am    
thank you
The proper query is:
SQL
SELECT ID, firstName
FROM human AS U WHERE U.ID = 2


I strongly recommend to read some tutorial, for example: http://www.w3schools.com/sql/[^]
 
Share this answer
 
Comments
m.mongolia 5-Aug-14 11:04am    
thank you
Maciej Los 5-Aug-14 16:03pm    
You're welcome.
Please, accept all valuable answers as a solution (green button) - formally to remove your question from unanswered list.

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

  Print Answers RSS


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