2014-10-27 109 views
0

我想使用t2中的數據更新t1中的選定行。我認爲的UPDATE/INNER JOIN是好的,但我不知道如何限制在合併報表更新爲那些在選擇行:使用INNER JOIN SQL選擇行更新

SELECT * FROM exp_channel_titles WHERE channel_id = 12 

UPDATE exp_channel_data t1 
INNER JOIN exp_channel_titles t2 ON t1.entry_id = t2.entry_id 
SET t1.field_id_131 = t2.url_title 

我怎樣才能做到這一點?

回答

0

你試過:

UPDATE exp_channel_data t1 
INNER JOIN exp_channel_titles t2 ON t1.entry_id = t2.entry_id AND t2.channel_id = 12 
SET t1.field_id_131 = t2.url_title