Error Code: 1093. You can’t specify target table ‘t_user’ for update in FROM clause 0.015 SEC
data cannot be query in the same table as update data in the same table.
note that this problem occurs only in mysql; MSSQL and oracle do not.
Keyword search: mysql Error 1093
Example:
delete from t_user where id in (select id from t_user where id > 26);
Error Code: 1093. You can’t specify target table ‘t_user’ for update in FROM clause 0.000 SEC
Solution: select the result of the select through the intermediate table again, so as to avoid the error
change the SQL statement to:
delete from t_user where id in (select * from (select id from t_user where id > 26) tmp);
Then optimize it:
delete t from t_user t join (select id from t_user where id > 22) tmp on tmp.id = t.id;
query data in the same table as the same table update or delete delete, the SQL statement is as follows:
select * from (clause temp)
Read More:
- MySQL error set: failed to start mysql.service : Unit mysql.service is masked.
- MySQL local connection Error 1130_ The solution of MySQL 1130 error report when remote connection through Navicat for MySQL
- MySQL – ERROR 1146 (42S02): Table ‘mysql.user’ doesn’t exist
- MySQL error — multiple methods of failed to find valid data directory and MySQL setting password appear
- Mysql Error:The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist
- It can’t connect to local MySQL server through socket ‘/ tmp/ mysql.sock ‘(2) “;
- (error when importing database): MySQL 2006-mysql server has gone away
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- MySQL Workbench: Error Code: 2013. Lost connection to MySQL server during query solution
- Question: cannot create windows service for mysql.error : 0 (install MySQL)
- After installing MySQL again under Linux, the solution of ‘MySQL module failed to start’ appears
- The MySQL service suddenly hangs up with the error message can’t connect to MySQL server on ‘localhost’ (10061)
- Error in installing MySQL devel for CentOS MySQL
- Golang MySQL error SQL: unknown driver “MySQL” (Forgotten import?) solution
- MySQL installation failed: dpkg: error processing package MySQL server (- – configure): dependency problem
- django.core.exceptions . improveconfigured: error loading MySQL DB module. Django configuring MySQL database
- Solve MySQL installation error: initializing database prompts an error when installing mysql
- PHP connection to MySQL database error: call to undefined function MySQL_ connect()
- When MySQL is running, the server suddenly goes down, which causes Mysql to be unable to restart
- MySQL Workbench Failed to Connect to MySQL at 127.0.0.1:3306 with user root Bad handshake