mysql-error-1093

MySQL #1093 - You can't specify target table 'giveaways' for update in FROM clause

梦想的初衷 提交于 2019-11-26 09:09:58
问题 I tried: UPDATE giveaways SET winner = \'1\' WHERE ID = (SELECT MAX(ID) FROM giveaways) But it gives: #1093 - You can\'t specify target table \'giveaways\' for update in FROM clause This article seems relevant but I can\'t adapt it to my query. How can I get it to work? 回答1: This is because your update could be cyclical... what if updating that record causes something to happen which made the WHERE condition FALSE ? You know that isn't the case, but the engine doesn't. There also could be

You can't specify target table for update in FROM clause

时间秒杀一切 提交于 2019-11-26 03:13:00
问题 I have a simple mysql table: CREATE TABLE IF NOT EXISTS `pers` ( `persID` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(35) NOT NULL, `gehalt` int(11) NOT NULL, `chefID` int(11) DEFAULT NULL, PRIMARY KEY (`persID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; INSERT INTO `pers` (`persID`, `name`, `gehalt`, `chefID`) VALUES (1, \'blb\', 1000, 3), (2, \'as\', 1000, 3), (3, \'chef\', 1040, NULL); I tried to run following update, but I get only the error 1093: UPDATE pers P SET P

MySQL Error 1093 - Can't specify target table for update in FROM clause

痴心易碎 提交于 2019-11-26 01:17:25
问题 I have a table story_category in my database with corrupt entries. The next query returns the corrupt entries: SELECT * FROM story_category WHERE category_id NOT IN ( SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id); I tried to delete them executing: DELETE FROM story_category WHERE category_id NOT IN ( SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id=category.id); But I get the next error: #1093 - You can\'t