2014-02-18 250 views
-4
UPDATE student 
     INNER JOIN 
    fee_head2 ON (student.new_old = fee_head2.new_old) 
     INNER JOIN 
    fee_head2 ON (student.class = fee_head2.class) 
SET 
    student.head1_apr = fee_head2.head1_apr 

這是顯示#1066 - 非唯一表/別名:'fee_head2'。需要更正mysql查詢

任何人都可以糾正這個查詢對我嗎?

+1

嘗試使用表的別名 –

+0

我新,你可以請建議 – alleged

+0

但重申一個內部聯接......這就是問題所在! – 2014-02-18 11:17:38

回答

2

無需再加入同一個表,試試這個:

UPDATE student INNER JOIN fee_head2 
ON (student.new_old = fee_head2.new_old) 
AND (student.class = fee_head2.class) 
SET student.head1_apr = fee_head2.head1_apr 
0

阿齊茲打我明顯naswer。

UPDATE student SET student.head1_apr = 
CASE 
    WHEN student.new_old = fee_head2.new_old AND student.class = fee_head2.class THEN fee_head2.head1_apr 
    ELSE NULL 
END