[SQL] Show ads from the parent category
Hi,
This is my SQL below... I have specific ads (paid ads with cp_pack_id=3 ) but how can i have only the ads from the parent category?
SELECT DISTINCT *
FROM $wpdb->posts, $wpdb->postmeta, $table_name AS t
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND t.postnum = $wpdb->posts.ID
AND $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = '$post_type'
AND $wpdb->postmeta.meta_key = 'cp_pack_id'
AND $wpdb->postmeta.meta_value = '3'
GROUP BY $wpdb->posts.ID
ORDER BY t.postcount DESC LIMIT $limit
many thanks for your help