Did you do any search/replace on that query before posting? On the face of it, WooCommerce Subscriptions is doing a search on a table with the prefix wp_, but other tables with the prefix xxxx_, which is incorrect.
David
Thread Starter
mrfm
(@mrfm)
Yes I did, sorry. Just to remove the real db and table names.
So, was wp_ the real prefix? Or some of them got replaced with different things to the others? I’m trying to work out if the above query is valid.
Thread Starter
mrfm
(@mrfm)
Here is another one with less editing:
1) WordPress database error Table ‘xxxxxxx1_zfrm2.wp_postmeta’ doesn’t exist for query SELECT SUM(order_total_meta.meta_value)
FROM wp_postmeta as order_total_meta
RIGHT JOIN
(
SELECT DISTINCT wcorder.ID
FROM zfrm_posts AS wcorder
INNER JOIN zfrm_postmeta AS meta__subscription_renewal
ON (
wcorder.id = meta__subscription_renewal.post_id
AND
meta__subscription_renewal.meta_key = ‘_subscription_renewal’
)
WHERE wcorder.post_type IN ( ‘shop_order’ )
AND wcorder.post_status IN ( ‘wc-completed’, ‘wc-processing’, ‘wc-on-hold’, ‘wc-refunded’ )
AND wcorder.post_date >= ‘2019-02-01’
AND wcorder.post_date < ‘2019-02-09’
) AS orders ON orders.ID = order_total_meta.post_id
WHERE order_total_meta.meta_key = ‘_order_total’ made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->status_widget, do_action(‘woocommerce_after_dashboard_status_widget’), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Report_Dashboard::add_stats_to_dashboard, WCS_Report_Dashboard::get_data
———————————————————————-
Last seen: 52 mins ago (Feb 08, 17:48:14)
First seen: 9 hours ago (Feb 08, 09:54:51)
Total events: 3
———————————————————————-
2) WordPress database error Table ‘xxxxxxx1_zfrm2.wp_postmeta’ doesn’t exist for query SELECT SUM(order_total_meta.meta_value)
FROM wp_postmeta as order_total_meta
RIGHT JOIN
(
SELECT DISTINCT wcorder.ID
FROM zfrm_posts AS wcsubs
INNER JOIN zfrm_posts AS wcorder
ON wcsubs.post_parent = wcorder.ID
WHERE wcorder.post_type IN ( ‘shop_order’ )
AND wcsubs.post_type IN ( ‘shop_subscription’ )
AND wcorder.post_status IN ( ‘wc-completed’, ‘wc-processing’, ‘wc-on-hold’, ‘wc-refunded’ )
AND wcorder.post_date >= ‘2019-02-01’
AND wcorder.post_date < ‘2019-02-09’
) AS orders ON orders.ID = order_total_meta.post_id
WHERE order_total_meta.meta_key = ‘_order_total’ made by wp_dashboard, do_meta_boxes, WC_Admin_Dashboard->status_widget, do_action(‘woocommerce_after_dashboard_status_widget’), WP_Hook->do_action, WP_Hook->apply_filters, WCS_Report_Dashboard::add_stats_to_dashboard, WCS_Report_Dashboard::get_data
Whichever plugin is creating that query has hard-coded wp_ as the table prefix, instead of consulting what your WP install’s actual table prefix, here:
FROM wp_postmeta
This is a coding error in the plugin concerned, that should be reported to its author.