Last active
February 7, 2024 09:36
-
-
Save Nav-Appaiya/cc21ae8e5a8111c9ac02f3be79d0caeb to your computer and use it in GitHub Desktop.
Delete all woocommerce orders before a specific data [with SQL]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM wp_woocommerce_order_items WHERE order_id IN ( SELECT ID FROM wp_posts WHERE post_date BETWEEN '2019-01-01' AND '2023-01-01'); | |
DELETE FROM wp_comments WHERE comment_type = 'order_note' AND comment_post_ID IN ( SELECT ID FROM wp_posts WHERE post_date BETWEEN '2019-01-01' AND '2023-01-01' AND post_type='shop_order'); | |
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_date BETWEEN '2019-01-01' AND '2023-01-01' AND post_type = 'shop_order'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DELETE FROM wp_woocommerce_order_items WHERE order_id IN ( SELECT ID FROM wp_posts WHERE post_date >= '2019-01-01')
DELETE FROM wp_comments WHERE comment_type = 'order_note' AND comment_post_ID IN ( SELECT ID FROM wp_posts WHERE post_date BETWEEN '2019-01-01' AND '2023-01-01')
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_date BETWEEN '2019-01-01' AND '2023-01-01')
DELETE FROM wp_posts WHERE post_type = 'shop_order' AND post_date BETWEEN '2019-01-01' AND '2023-01-01';