我想获取meta\\u key==“parent\\u id”的相同meta\\u值的数目或计数。我怎样才能得到它?wordpress查询同一个表中的记录应该是什么?
//set the meta_key to the appropriate custom field meta key
$meta_key = \'parent_id\';
$allmiles = $wpdb->get_var( $wpdb->prepare(
"SELECT meta_value,
SUM(IF(meta_value = "Purva", 1,0)) AS \'parent_id\',
COUNT(meta_value) AS \'total\'
FROM $wpdb->wp_postmeta
GROUP BY post_id
ORDER BY parent_id DESC",
$meta_key
) );
echo "<p>Total miles is {$allmiles}</p>";