我有2個表:員工和人與結構返回列名其中加入條件爲空
Employee: Id, PersonId, Designation, IsActive
Person:Id, Name, Contact
員工PERSONID列引用人的身份證,並可以爲空
我需要返回一個僱員的名稱和我一起的標準是
SELECT emp.Salary, emp.Designation, emp.IsActive, p.Name from Employee emp
JOIN Person P ON P.Id = emp.PersonId or (p.Id is NULL AND emp.Id IS NULL)
這是不正確的,我的要求是:
If emp.PersonId = null, return p.Name = NULL
else return p.Name = Person's Name from table
任何指針?
我有種感覺,你可以有一個不在人桌子上的員工。 – HLGEM 2010-11-16 16:29:04