DELETE FROM tickets WHERE updatedate < DATE_ADD(NOW(),INTERVAL - 30 DAY);
DELETE FROM ticketdata WHERE ticketid NOT IN ( SELECT ticketID FROM tickets );
DELETE FROM timeslips WHERE ticketid NOT IN ( SELECT ticketID FROM tickets );
DELETE FROM Databasefails WHERE ticketid NOT IN ( SELECT ticketID FROM tickets );
DELETE FROM Databasealerts WHERE ticketid NOT IN ( SELECT ticketID FROM tickets );
DELETE FROM plugin_cw_ticket_failures WHERE ticketid NOT IN ( SELECT ticketID FROM tickets );
DELETE FROM Projects WHERE ticketid NOT IN ( SELECT ticketID FROM tickets );