Custom $wpdb queries.. need help
-
I’m sure this looks horrible, but it is my first time doing a custom query using $wpdb
I am trying to grab the total values from a meta_value in the commentmeta table assigned a specific post id with a specific meta_key of ‘rating’.. but I’m not sure what I’m doing wrong.. here is my code
<?php global $wpdb; $rating = $wpdb->get_var(" SELECT SUM($wpdb->commentmeta.meta_value) FROM $wpdb->posts, $wpdb->commentmeta, $wpdb->comments WHERE $wpdb->posts.ID='46' AND $wpdb->commentmeta.meta_key='rating'"); echo $rating; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom $wpdb queries.. need help’ is closed to new replies.