You can't specify target table '##' for update in FROM clause

错误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) )

报错信息:

You can't specify target table 'tb_lts_intent_pattern' for update in FROM clause

错误原因:

MySQL中,不能先select出同一表中的某些值,再update这个表(在同一语句中)。

正确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 = "电影名"

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容