【MySQL】ERROR 1093 You can
【問題描述】:
Error: 1093 SQLSTATE: HY000 ()
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
- why you can be in netherland
- [ERROR] Can't open the mysql.plugin tableErrorMySqlPlugin
- 完美解決stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.ErrorPython
- 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
- MySQL 5.5 原始碼安裝報錯"[ERROR] Can't start server"MySql原始碼ErrorServer
- You can‘t specify target table ‘Person‘ for update in FROM clause
- oracle和mysql關於關聯更新的一些差別以及ERROR 1093OracleMySqlError
- 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
- S2 - Lesson 57 - Can I help you, madam?
- 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
- 錯誤內容:You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverErrorMySqlServer
- [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
- 如何解決"You have an error in your SQL syntax"ErrorSQL
- [LeetCode] 1953. Maximum Number of Weeks for Which You Can WorkLeetCode
- 排錯./configure: error: the HTTP XSLT module requires the libxml2/libxslt libraries. You can either doErrorHTTPUIXML