How to Fix Error 1093 Error – MySQL Error 1093 - Can't specify target table for update in FROM clause
MySQL Error 1093 - Can't specify target table for update in FROM clause
📋 Table of Contents
The MySQL Error 1093 - Can't specify target table for update in FROM clause error occurs when you're trying to delete data from a table using an IN or NOT IN clause with another table. This is because the subquery in the WHERE clause doesn't have a LIMIT clause, which means it returns all rows from the category table.
🛑 Root Causes of the Error
- Missing LIMIT clause in subquery
✅ Best Solutions to Fix It
Method 1: Using LIMIT in Subquery
- Step 1: Modify the subquery to include a LIMIT clause, like this:
DELETE FROM story_category WHERE category_id NOT IN (SELECT DISTINCT category.id FROM category INNER JOIN story_category ON category_id = category.id LIMIT 100);Method 2: Using EXISTS or NOT EXISTS Instead of IN
- Step 1: Replace the IN clause with an EXISTS or NOT EXISTS clause, like this:
DELETE FROM story_category WHERE NOT EXISTS (SELECT 1 FROM category INNER JOIN story_category ON category_id = category.id);💡 Conclusion
By applying one of these solutions, you should be able to fix the MySQL Error 1093 - Can't specify target table for update in FROM clause and successfully delete corrupt entries from your story_category table.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: hidden network issues by identifying and removin
Resolve hidden network issues by identifying and removing a problemati
How to Fix: Galaxy Z Fold sound issues by checking audio set
Fix Galaxy Z Fold sound issues by checking audio settings, resetting a
How to Fix: Bluetooth connectivity issues on Windows by upda
Resolve Bluetooth connectivity issues on Windows by updating your driv