Ищем в таблице article
SELECT * FROM otrs.article;
Нужный нам тикет
SELECT * FROM otrs.ticket;
Удаляем из article — указываем ID строки с нужным тикетом, их может быть несколько.
-- Удаляем article
START TRANSACTION;
-- Provide the values of the primary key of the row to delete.
SET @id_to_delete = ID;
DELETE FROM article_attachment
USING article_attachment, article
WHERE `article`.`id` = `article_attachment`.`article_id`
AND article.id = @id_to_delete;
DELETE FROM article_flag
USING article_flag, article
WHERE `article`.`id` = `article_flag`.`article_id`
AND article.id = @id_to_delete;
DELETE FROM article_plain
USING article_plain, article
WHERE `article`.`id` = `article_plain`.`article_id`
AND article.id = @id_to_delete;
DELETE FROM ticket_history
USING ticket_history, article
WHERE `article`.`id` = `ticket_history`.`article_id`
AND article.id = @id_to_delete;
DELETE FROM time_accounting
USING time_accounting, article
WHERE `article`.`id` = `time_accounting`.`article_id`
AND article.id = @id_to_delete;
DELETE FROM article
USING article
WHERE article.id = @id_to_delete;
COMMIT;
После этого удаляем сам тикет, по его ID
-- Удаляем ticket
START TRANSACTION;
-- Provide the values of the primary key of the row to delete.
SET @id_to_delete = ID;
DELETE FROM ticket_flag
USING ticket_flag, ticket
WHERE `ticket`.`id` = `ticket_flag`.`ticket_id`
AND ticket.id = @id_to_delete;
DELETE FROM ticket_history
USING ticket_history, ticket
WHERE `ticket`.`id` = `ticket_history`.`ticket_id`
AND ticket.id = @id_to_delete;
DELETE FROM ticket_index
USING ticket_index, ticket
WHERE `ticket`.`id` = `ticket_index`.`ticket_id`
AND ticket.id = @id_to_delete;
DELETE FROM ticket_lock_index
USING ticket_lock_index, ticket
WHERE `ticket`.`id` = `ticket_lock_index`.`ticket_id`
AND ticket.id = @id_to_delete;
DELETE FROM ticket_watcher
USING ticket_watcher, ticket
WHERE `ticket`.`id` = `ticket_watcher`.`ticket_id`
AND ticket.id = @id_to_delete;
DELETE FROM time_accounting
USING time_accounting, ticket
WHERE `ticket`.`id` = `time_accounting`.`ticket_id`
AND ticket.id = @id_to_delete;
DELETE FROM ticket
USING ticket
WHERE ticket.id = @id_to_delete;
COMMIT;