MySQL Error 1093⏱️ 2 min read📅 2026-05-30

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

Quick Answer: The error occurs because the subquery in the NOT IN clause is not properly correlated with the outer query. To fix this, use a JOIN instead of NOT IN.

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

  1. 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

  1. 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.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions