Home > Database > Mysql Tutorial > body text

MYSQL #1093_MySQL

WBOY
Release: 2016-06-01 13:51:27
Original
1194 people have browsed it

目前在写程序时,在处理MYSQL时遇到一个问题,问题如下

update dealer_admin set is_super_admin=1 where id in (select id from dealer_admin group by dealer_id );
Copy after login

此时会报:#1093 - You can't specify target table 'dealer_admin' for update in FROM clause

在网上找了一个暂时可以解决的方法

create temporary table tmp (id int);<br>insert into tmp (id) select id from dealer_admin group by dealer_id;<br>update dealer_admin set is_super_admin=1 where id in (select id from tmp);
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!