Request failed

When I entered the code as shown below, I am returning this error:

Msg 116, Level 16, State 1, Line 1
Only one expression can be specified in the selection list if a subquery is not entered 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))
+4
source share
4 answers

Problem here

 E_ID NOT IN (SELECT * FROM SALARY_ADVANCE))

You must specify one column instead of all

+9
source

The problem is in this line:

E_ID NOT IN (SELECT * FROM SALARY_ADVANCE)

You must indicate in which field you are checking this SELECT. Otherwise, you get a table, not a set of values.

E_ID NOT IN (SELECT FIELD_NAME FROM SALARY_ADVANCE)
+7
source

NOT IN , , NULL. , , ... IS NOT NULL , .

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 E_ID 
                        FROM SALARY_ADVANCE
                      WHERE E_ID IS NOT NULL)

NOT EXISTS, .

SELECT E_ID, 
       E_NAME, 
       PROJECT, 
       MANAGER
  FROM EMPLOYEE_PROJECT INNER JOIN EMP_MASTER ON (
         EMPID = E_ID AND 
         LOCATION = 'MUMBAI' AND 
         NOT EXISTS (SELECT E_ID 
                     FROM SALARY_ADVANCE as SA
                     WHERE SA.E_ID = EMP*table*.E_ID))
+3
source
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 E_ID 
                        FROM SALARY_ADVANCE)
+2
source

Source: https://habr.com/ru/post/1613436/


All Articles