SELECT b.post_title, a.post_id, COUNT( * ) as Total
FROM wp_posts b INNER JOIN
wp_postmeta a ON a.post_id = b.ID
WHERE a.meta_value = 1
AND a.meta_key = 'type-select'
AND b.post_status = 'publish'
and post_type = 'car-cc'
GROUP BY b.post_title, a.post_id
Currently it select’s post title
and post id
but i also need to select a meta value
where meta key = type-gen the problem is another meta key is already compared in the query.
SQL Fiddle: http://sqlfiddle.com/#!2/109c2/1
Here you go
Fiddle
Use WP_Query for this,
Modified from the Codex page