錯(cuò)誤sql :
update tb_lts_intent_pattern set del_status = 0 where id in
(select id from tb_lts_intent_pattern where del_status = 1 and intent_id not in
(select id from tb_lts_intent where del_status = 1) )
報(bào)錯(cuò)信息:
You can't specify target table 'tb_lts_intent_pattern' for update in FROM clause
錯(cuò)誤原因:
MySQL中,不能先select出同一表中的某些值,再update這個(gè)表(在同一語句中)。
正確sql :
update tb_lts_intent_pattern set del_status = 0 where id in
(select a.id from (select id from tb_lts_intent_pattern where
del_status = 1 and intent_id not in
( SELECT id from tb_lts_intent where del_status = 1 )) a)
迄今為止寫的最牛逼的sql
update tb_lts_dict set value = 0.3 * (2 / PI() * ATAN(log(2, freq + 2))) + 0.7 * ((freq-(select a.min from (select MIN(freq) as min from tb_lts_dict where nature = '電影名') a) + 1)/ ((select b.max from (select MAX(freq) as max from tb_lts_dict where nature = '電影名') b) - (select c.min from (select MIN(freq) as min from tb_lts_dict where nature = '電影名') c) + 1 )) where nature = "電影名"