while using multiple in getting error in sql
I have a query like this:
SELECT em.Ename
FROM dbo.Email_tbl e
JOIN dbo.EmployeeMaster_tbl em ON em.Ecode = e.ECode
WHERE e.plcid='25'
which gives me an output like this:
Ename
-------------------
Ahmed
Ahmed Elkhouli
akbar
Alaudddin
I have another query like this:
SELECT e.Ename
from dbo.EmployeeMaster_tbl e
WHERE e.gid not IN(SELECT did
FROM dbo.Designation_tbl d
WHERE d.Dname ='Driver' )
And I am getting output like this:
Ename
--------------------------------------------------
Shaijomon John
Masum
Tausef Ahmad
Abdu Rahiman
Mohammad Shopan
Benzy P A
Mohammad Ali
Kauser Mohammad
Rasheed Pulakkuttathil
Lakshuman Perappan
Ahmed
Ahmed Elkhouli
akbar
Alaudddin
I need to output ename for rows that are not present in the first query.
so I tried query like this:
SELECT e.Ename
from dbo.EmployeeMaster_tbl e
WHERE e.gid not IN(SELECT did
FROM dbo.Designation_tbl d
WHERE d.Dname ='Driver')
and not in (SELECT em.Ename
FROM dbo.Email_tbl e
JOIN dbo.EmployeeMaster_tbl em ON em.Ecode = e.ECode
WHERE e.plcid='25')
order by e.Ename
but I am getting an Incorrect syntax error near the keyword in.
No comments:
Post a Comment