Custom Query for wp_posts using wp_postmeta
While you might not want / be able to use native query, it is still the easiest and most reliable way to generate SQL like that. $wpdb->last_query will remember last query performed and defining SAVEQUERIES constants will make $wpdb->queries contain all of the queries performed in current load (not advisable in production for performance). So … Read more