我有以下sql。
update voting_table
Set VOTING_STATUS = 1
where CE_ID = 15813
and
VOTING_PK =
(SELECT VOTING_PK FROM voting_table
ORDER BY VOTING_PK DESC
LIMIT 1) ;
但编辑器向我显示以下错误:
Error code 1093, SQL state HY000: You can't specify target table 'voting_table' for update in FROM clause
如何克服错误?请帮我 。
答案 0 :(得分:1)
我认为这些SQL对您有所帮助。
update voting_table as table_1, (SELECT VOTING_PK FROM voting_table ORDER BY VOTING_PK DESC LIMIT 1) as table_2
where table_1.VOTING_PK = table_2.VOTING_PK and CE_ID = 15813
Set VOTING_STATUS = 1
谢谢。