Jump to content

DELETE query not working


EchoFool

Recommended Posts

Hey,

 

I have a query which is meant to delete all rows which are less than the last 31 ids with this WHERE clause. As i only display the most latest 31 rows the rows that are any older might aswell be deleted but it won't work for me.

 

The error i get is:

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

 

DELETE FROM messages 
WHERE id <  (SELECT MAX(id) FROM messages) - 31 

 

Hope you can help! :)

Link to comment
https://forums.phpfreaks.com/topic/204509-delete-query-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.