sqlquery with self join questions
I have an "emp" table with below records
INSERT into emp(EmpId,开发者_开发知识库Emp name, ManagerId)
Values(1,A,2)
values(2,B,3)
values(3,C,4)
values(4,D,-)
How can i find the Employee who does not have a Manager ie in this case the result should be D.
Typically it would be like this.
SELECT EmpId, [Emp Name], ManagerId
FROM Emp
WHERE ManagerId is Null
Your example is
SELECT EmpId, [Emp Name], ManagerId
FROM Emp
WHERE ManagerId = '-'
SELECT EmpId, Emp name, ManagerId
FROM Emp
WHERE ManagerId IS NULL (or ManagerId='-' in your example)
精彩评论