Hi guys,
I have a problem with deleting duplicate records from mysql table, mysql version is above 5
DELETE FROM `tbl_video_category` WHERE category_id NOT IN (
SELECT MAX( category_id )
FROM `tbl_video_category`
GROUP BY category_name )
Error message showing that 'You can't specify target table 'tbl_video_category' for update in FROM clause'
Any help would be appreciated
Thanks.
Delete duplicate records from mysql table
Moderator: General Moderators
-
ashik pasha
- Forum Newbie
- Posts: 9
- Joined: Mon Dec 01, 2008 9:55 pm
Re: Delete duplicate records from mysql table
Try a different query:
I think that should work. Otherwise
Code: Select all
DELETE FROM table ORDER BY field DESC LIMIT 1Code: Select all
DELETE FROM table WHERE primarykey = (SELECT primarykey FROM table ORDER BY field DESC LIMIT 1)-
ashik pasha
- Forum Newbie
- Posts: 9
- Joined: Mon Dec 01, 2008 9:55 pm
Re: Delete duplicate records from mysql table
The same error repeating again ....why this error showing when mysql support sub queries.. have you any idea..? Inner query working well...
If this query wont work correctly ... can you give me a solution for deleting multiple records from table(cat_id,cat_name)
If this query wont work correctly ... can you give me a solution for deleting multiple records from table(cat_id,cat_name)