I have an update query to make better.
CREATE TABLE `tickets` (
`ticket_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`client_update` INT UNSIGNED NOT NULL ,
`staff_update` INT UNSIGNED NOT NULL
) ENGINE = MYISAM ;
CREATE TABLE `ticket_posts` (
`post_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`ticket_id` INT UNSIGNED NOT NULL ,
`reply_by` ENUM( 'client', 'staff' ) NOT NULL
) ENGINE = MYISAM ;
UPDATE ticket SET staff_update_date = 0 WHERE ticket_id NOT IN ( SELECT ticket_id FROM ticket_posts WHERE reply_by = "staff" GROUP BY ticket_id );
Fixing a bug which was setting staff_update when it shouldn’t have. So any ticket without a “staff” post should have staff_update set to zero. The current query takes a while and makes the site hang while it’s running. I’m thinking a multi table UPDATE will be better but how would it be written? The negation is throwing me off.