I want to sum some field of dat开发者_Go百科abase table according to the employee id supplied in where. The problem is I want to supply multiple employee ids in a single query and want the sum accordingly. Separate sum for each employee. please help me.
You will need to use the GROUP BY clause.
SELECT SUM(`hours`), `employee_id` FROM `timetable` WHERE `employee_id` IN (1, 3, 8, 52) GROUP BY `employee_id`;
精彩评论