I have a few wordpress posts with multiple meta values...
Im trying to write a query that will find all posts with X values...
$customkey1 = 'Type of Vehicle';
$customvalue1 = $_POST['OPT1'];
$customkey1 = 'Network';
$customvalue1 = $_POST['OPT2'];
$my_posts = $wpdb->get_results("
SELECT * FROM $wpdb->posts, $wpdb->postmeta
WHERE ID = $wpdb->postmeta.post_id
AND meta_key = '$customkey'
AND meta_value = '$customvalue'
AND meta_key = '$customkey1'
AND meta_value = '$customvalue1'
AND $wpdb->posts.post_status = 'publish'
ORDER BY post_date DESC
");
I think where im going wrong is im saying 'WHERE meta_key' equals 1 thing but then im saying if it equals another, I need to see if any of the meta keys are the same, does this make sense?
Thanks