I’ve stored a bunch of post meta data inside a serialized array and I’m trying to write a custom SQL query that will only retrieve the results that are upcoming:
I’m currently at the following but It doesn’t seem to want to get the results.
MY outputted SQL is:
SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'cjd' AND ((wp_posts.post_status = 'publish')) AND ( ( wp_postmeta.meta_key = 'cjd_data' AND CAST(wp_postmeta.meta_value AS SIGNED) >= 'date' ) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC
And my functionality is:
$wpdb->query(
$wpdb->prepare( "SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'cjd' AND ((wp_posts.post_status = 'publish')) AND ( ( wp_postmeta.meta_key = 'cjd_data' AND CAST(wp_postmeta.meta_value AS SIGNED) >= 'date' ) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC")
);
I’ve tried everything and I can’t use meta_query on a custom $args as the date field is inside the serialized array.