我有三张表如下
成绩 id,emp_id,area,dat
calls_per_day id,emp_id,noofcalls,hotcalls,hotleads,dat
sales_statistics_master id,emp_id,target,commitment,mnth,yrs
现在我想从以上三个表格中提取员工的数据,了解他的成就,noofcalls,hotcalls,hotleads perdayday兑换每月目标和承诺。
我正在使用以下查询。
SELECT a.area, s.target,s.commitment,c.noofcalls,c.hotcalls,c.hotleads
FROM achievement as a, sales_statistics_master as s, calls_per_day as c
WHERE a.dat=CURDATE() AND
c.dat=CURDATE() AND
s.yrs= year(now()) AND
a.emp_id=s.emp_id AND
a.emp_id=c.emp_id
答案 0 :(得分:0)
使用(字段)连接。
select a.area, s.target,s.commitment,c.noofcalls,c.hotcalls,c.hotleads from
achievement as a join
sales_statistics_master as s using(emp_id) join
calls_per_day as c using(emp_id)
where a.dat=CURDATE() AND c.dat=CURDATE() AND s.yrs= year(now())