而连接两个表,我执行的一个查询,但它显示不正常第二表数据,而不是它显示垃圾值..当在mysql中连接两个表时,我在'on子句'“中收到错误信息”未知列'm.machinenumber'?
i用于查询,
select p.machinenumber,
max(case when (p.shift)=1 then xxxx end) s1_xxxx,
max(case when (p.shift)=2 then xxxx end) s2_xxxx,
avg(case when (p.shift)=1 then yyyy end) s1_yyyy ,
avg(case when (p.shift)=2 then yyyy end) s2_yyyy
from pdata p
inner join (select count(case when (shift)=1 and (ename)=1 then ename end) s1_wa,
count(case when (shift)=1 and (ename)=2 then errorname end) s1_we,
count(case when (shift)=2 and (ename)=1 then errorname end) s2_wa,
count(case when (shift)=2 and (ename)=2 then ename end) s2_we,
count(case when (shift)=1 and (ename)=0 then ename end) s1_merror,
count(case when (shift)=2 and (ename)=0 then ename end) s2_merror from mstop)m
on p.mnumber=m.mnumber
where date(p.proddate)='2013-02-25';
请解决这个问题??
男人我这次殴打你...对不起,但你每次回答我之前,当我试图写回答,所以我后来删除我的答案,但现在我击败了你。 – 2013-03-01 06:44:22
@DipeshParmar我对此没有任何问题(*对我来说不是什么大问题),但我想知道为什么每次我回答问题时最终都会删除您的答案?我不告诉你删除它。我不会与这里的任何其他用户竞争。让我问你,你确定查询给你正确的结果,即使你已经在子查询中添加了'mnumber'吗? ':D' – 2013-03-01 06:49:15
nope永远..我永远不会删除任何答案或永远不投票任何人没有极端的条件...你可以看到向下投票率是低得多在我的个人资料.. – 2013-03-01 06:52:34