有
5
张表:(项目表)
item_table(salaryid,salaryitem,salarynumber,itemid);
(
人员考核表
)kaohe_table(kaoheid,id,salaryid,nowtime);
(
人员表
)name_table (id,name);
(
考核类型
)type_table (itemid,items,itemnumber)
(
联合查询要写回数据的表
)display_table (displayid,name,safty,service,clear,quality,method,countmoney,nowtiem)
查询语名:
string sql = "SELECT b.name, SUM(CASE c.itemid WHEN '1' THEN c.salarynumber ELSE 0 END) AS a, SUM(CASE c.itemid WHEN '2' THEN c.salarynumber ELSE 0 END) AS b, SUM(CASE c.itemid WHEN '3' THEN c.salarynumber ELSE 0 END) AS c, SUM(CASE c.itemid WHEN '4' THEN c.salarynumber ELSE 0 END) AS d, SUM(CASE c.itemid WHEN '5' THEN c.salarynumber ELSE 0 END) AS e, a.nowtime FROM kaohe_table AS a INNER JOIN name_table AS b ON a.id = b.id INNER JOIN Item_table AS c ON a.salaryid = c.salaryid INNER JOIN Type_table AS d ON c.itemid = d.itemid WHERE (a.nowtime = '"+要查询时间+"') GROUP BY b.name, a.nowtime";
以上联系合查询出的a,b,c,d,e,nowtime各个列的数据写回到display_table表相应的字段中去. a---对应字段-------safty b----对应字段------service c----对应字段-------clear d-----对应字段----quality
以上联系合查询出的a,b,c,d,e,nowtime各个列的数据写回到display_table表相应的字段中去. a---对应字段-------safty b----对应字段------service c----对应字段-------clear d-----对应字段----quality
查询出的结果,我不知道如何写回到display_table表中去,请高手帮忙.谢谢.