JOIN query ON wp_posts and wp_postmeta


<?php

$results_count = $wpdb->get_var(“SELECT count(ID) FROM wp_posts JOIN wp_postmeta WHERE wp_posts.ID = wp_postmeta.post_id AND wp_posts.post_type=’aviweb’ AND wp_postmeta.meta_key=’website’ AND wp_postmeta.meta_value=’aviweb.wordpress.com'”);

echo $results_count;

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s