Notes:
- The return from SELECT version()is 10.5.12-MariaDB-log
- Default collation: utf8mb4_unicode-ci
- Default charset: utf8mb4
- Queries run using MySQL Workbench for Ubuntu Linux 8.0.29
My goal is to delete duplicated items in a table. I do not have any other table to use as a reference to check duplicates. I created a simple query and subquery that returns expected results:
    SELECT * FROM messages WHERE id NOT IN
        (SELECT id FROM
            messages
        WHERE
            uid = '11899414026778263'
        GROUP BY message_id , uid
        ORDER BY created_at);
Despite setting SQL_SAFE_UPDATES to 0, a DELETE operation using the same data fails. I get a "QUERY Interrupted" message.
    SET SQL_SAFE_UPDATES = 0;
    DELETE FROM messages WHERE id NOT IN
        (SELECT id FROM
            messages
        WHERE
            uid = '11899414026778263'
        GROUP BY message_id , uid
        ORDER BY created_at);
    SET SQL_SAFE_UPDATES = 1;
If I replace DELETE with SELECT *, the query returns results. Another StackOverflow answer said that querying based on a sub-query does not work in MySQL. Others say to use another table as reference instead of a subquery.
DELETE query results in 'Query Interrupted' MySQL Workbench?
This method works in some SQL implementations based on these answers and websites:
 
    