How can i bulk delete old data?

Support forumCategory: QuestionsHow can i bulk delete old data?
Tom asked 4 years ago
Hi, for privacy and law and order :). We have a booking system for our sport club. But we have no interest to keep the data forever. We will delete a bunch of data older 30 Days. Is there a sql - Statement or maybe a in future a option where i can select automatic delete?   Thx for help Tom
Question Tags:
1 Answers
Nikola Loncar Staff answered 4 years ago
Hi Tom, here you go:
DELETE FROM wp_ea_fields WHERE app_id IN (SELECT id FROM wp_ea_appointments where `date` < now() - interval 30 DAY); DELETE FROM wp_ea_appointments where `date` < now() - interval 30 DAY;
but I would suggest that you first have a dry run by replacing DELETE FROM with SELECT * FROM just to see results. Also one more thing all user related Appointments data (those one from fields are stored inside fields table) so maybe replacing those values with empty values could be better solution. If you want to track money flow or have some global stats that don't expose particular user data :) Best regards, Nikola