Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute the query

Tags:

sql

sql-server

When I entered the code like shown below, I get back this error:

Msg 116, Level 16, State 1, Line 1
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

Code:

SELECT 
    E_ID, E_NAME, PROJECT, MANAGER
FROM 
    EMPLOYEE_PROJECT 
INNER JOIN 
    EMP_MASTER ON (EMPID = E_ID AND LOCATION = 'MUMBAI' AND 
                   E_ID NOT IN (SELECT * FROM SALARY_ADVANCE))
like image 934
Pala Bhaskar Avatar asked Nov 30 '22 10:11

Pala Bhaskar


2 Answers

Problem is here

 E_ID NOT IN (SELECT * FROM SALARY_ADVANCE))

You have to mention one column instead of all

like image 135
Anik Islam Abhi Avatar answered Dec 10 '22 02:12

Anik Islam Abhi


The issue in this line:

E_ID NOT IN (SELECT * FROM SALARY_ADVANCE)

You should mention what field you check in this SELECT. Otherwise you get a table set not a set of values.

E_ID NOT IN (SELECT FIELD_NAME FROM SALARY_ADVANCE)
like image 43
valex Avatar answered Dec 10 '22 03:12

valex