I have a table like this
x
EmpId No_of_days
1 24
2 28
6 24
7 30
8 10
9 15
when I write a select statement
SELECT No_of_days FROM _table WHERE EmpId = 3 or 4 or 5
I got an empty result set.
I want the result set return 0 days for employees 3 and 4 and 5
Advertisement
Answer
Assuming that you have another table with all your employees in (if not, where are employees 3, 4 and 5 coming from?), you could use a LEFT JOIN
onto your example table (_table
):
SELECT e.empid,
ISNULL(t.No_of_days,0)
FROM Employee e --No idea what your employee table is actually called, so guessed.
LEFT JOIN _table t ON e.empid = t.empid;
This will provide rows for all your employees. If you wanted just 3, 4 and 5, then you would add your WHERE
:
WHERE e.empid IN (3,4,5)