发布于 2016-03-29 08:15:37 | 238 次阅读 | 评论: 1 | 来源: 网友投递

这里有新鲜出炉的Mysql教程,程序狗速度看过来!

Mysql关系型数据库管理系统

MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQL AB公司。MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。


这篇文章主要介绍了mysql中You can’t specify target table for update in FROM clause错误解决方法,需要的朋友可以参考下

mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。 例如下面这个sql:



delete from tbl where id in 

(

        select max(id) from tbl a where EXISTS

        (

            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1

        )

        group by tac

)

改写成下面就行了:



delete from tbl where id in 

(

    select a.id from 

    (

        select max(id) id from tbl a where EXISTS

        (

            select 1 from tbl b where a.tac=b.tac group by tac HAVING count(1)>1

        )

        group by tac

    ) a

)

也就是说将select出的结果再通过中间表select一遍,这样就规避了错误。注意,这个问题只出现于mysql,mssql和oracle不会出现此问题。



最新网友评论  共有(1)条评论 发布评论 返回顶部
nomi 发布于2016-03-29 21:32:07
没效果啊
支持(0)  反对(0)  回复

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务