【MySQL】ERROR 1093 You can
【問題描述】:
Error: 1093 SQLSTATE: HY000 (ER_UPDATE_TABLE_USED)
Message: You can't specify target table '%s' for update in FROM clause
-
mysql> SHOW ERRORS;
-
+-------+------+----------------------------------------------------------------------------------------+
-
| Level | Code | Message |
-
+-------+------+----------------------------------------------------------------------------------------+
- | Error | 1093 | You can't specify target table 'table_name' for update in FROM clause |
- +-------+------+----------------------------------------------------------------------------------------+
-
1 row in set (0.02 sec)
常見的一個ERROR,在UPDATE時會出現,故DELETE時也有可能出現該問題。
大致意思是,不能根據某張表裡SELECT出來的條件去UPDATE(DELETE)。
比如如下語句:
-
DELETE FROM table_name
-
WHERE id IN
-
(SELECT id
-
FROM table_name
-
GROUP BY company_id
- HAVING COUNT(1)>1);
【解決方案】:
先將SELECT出來的結果集放入臨時表,再從臨時表取出條件:
比如:
-
DELETE FROM table_name
-
WHERE id IN
-
(SELECT a.id from
-
(SELECT id
-
FROM table_name
-
GROUP BY company_id
-
HAVING COUNT(1)>1) a
- );
作者公眾號(持續更新)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-1873900/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql報錯ERROR 1093MySqlError
- Mysql update in報錯 [Err] 1093 - You can't specify target table 'company_info' for update in FROM clauseMySql
- mysql中You can’t specify target table for update in FROM clMySql
- [ERROR] Can't open the mysql.plugin tableErrorMySqlPlugin
- mysql [ERROR] Can't create IP socket: Permission deniedMySqlError
- error:'Can'tconnecttolocalMySQLserverthroughsocket'/var/lib/mysql/mysql.sock'(2)'ErrorMySqlServer
- MYSQL ERROR 2003 (HY000) CanMySqlError
- MySQL "ERROR 1010(HY000):Error dropping database(canMySqlErrorDatabase
- Mysql報錯Fatal error:Can't open and lock privilege tablesMySqlError
- mysql can't connect error about privilege----not root userMySqlError
- JavaScript’s “this”: how it works, where it can trip you upJavaScript
- You can‘t specify target table ‘Person‘ for update in FROM clause
- oracle和mysql關於關聯更新的一些差別以及ERROR 1093OracleMySqlError
- MySQL 5.5 原始碼安裝報錯"[ERROR] Can't start server"MySql原始碼ErrorServer
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQLMySqlJDBCExceptionError
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- Composer 建立專案 You can also run `PHP --INI`PHP
- Microsoft's AI-powered app can help you learn ChineseROSAIAPP
- mysql報CanMySql
- Error: The action can not be performed because ...could not be locked?ErrorORM
- MySQL案例-不同尋常的[ERROR]Can't create a new thread (errno 11)MySqlErrorthread
- mysql [ERROR] InnoDB: ./ibdata1 can't be opened in read-write modeMySqlError
- 【MySQL】ERROR 1005 (HY000): Can't create table' (errno: 150)MySqlError
- [leetcode] 1642. Furthest Building You Can ReachLeetCodeUI
- I can't truly give chinese sex pills you a conclusive remedyREM
- 2008 5 19: I can't make exception for youException
- MySQL報錯'ERROR 2002 (HY000): Can't connect to local MySQL server through'MySqlErrorServer
- ERROR 2002(HY000):Can't connect to local MySQL socket '/tmp/mysql.sock'ErrorMySql
- ERROR in Entry module not found Error Can't resolve 'babel' in ' UseErrorBabel
- wireshark error: There are no interfaces on which a capture can be done.ErrorAPT
- mysqldump: Got error: 2002: Can't connect to local MySQL server through.....MySqlGoErrorServer
- 排錯./configure: error: the HTTP XSLT module requires the libxml2/libxslt libraries. You can either doErrorHTTPUIXML
- 關於MYSQL DML(UPDATE DELETE)中的子查詢問題和ERROR 1093 (HY000)錯誤MySqldeleteError
- Mac 下的MySQL ERROR 1227(42000): Access denied; you need (at least one of)MacMySqlErrorAST
- use database 切換提示You can turn off this feature to get a quicker startupDatabaseUI
- [筆記].痛哉!!!Error: Can't access JTAG chain, Error: Operation failed筆記ErrorAI
- ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sockErrorServerMySql
- 萬能方法解決——You have an error in your SQL syntaxErrorSQL