我試圖選擇帖子標題和兩個metafield值。但我不能得到正確的查詢.Y查詢被粘貼在下面請幫助。wpdb查詢加入帖子和帖子meta
$querystr = "
SELECT $wpdb->posts.post_title
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = side_post_meta_id
AND $wpdb->postmeta.meta_value LIKE %".$search_term."%
AND $wpdb->postmeta.meta_key = side_post_id
AND $wpdb->postmeta.meta_value LIKE %".$cat_find."%
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
ORDER BY $wpdb->posts.post_date DESC LIMIT 0,10
";
print_r($querystr);
$pageposts = $wpdb->get_results($querystr, OBJECT);
歡迎堆棧溢出。請閱讀以下關於如何在本網站上提出問題的文章:http://stackoverflow.com/help/how-to-ask。至少請提供您的表格結構,您的期望結果和實際結果。 –