Hello stackoverflow社区。我需要帮助。我有一份属于公司的城市名单。当我按类别过滤公司时,如果没有该公司的公司,我想删除公司的城市。所以我认为我需要检查是否有类别和城市的公司。所以我试过了:
$querystr = "
SELECT EXISTS(SELECT * FROM $wpdb->term_relationships, $wpdb->postmeta
WHERE $wpdb->term_relationships.object_id = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = 'country'
AND $wpdb->postmeta.meta_value = '$country_name'
AND $wpdb->postmeta.meta_key = 'city'
AND $wpdb->postmeta.meta_value = '$city_name
AND $wpdb->term_relationships.term_id = '$company_category'')
";
$pageposts = $wpdb->get_results($querystr);
但那不起作用,你能帮助我吗? :/
答案 0 :(得分:0)
AND $wpdb->postmeta.meta_value = '$city_name
AND $wpdb->term_relationships.term_id = '$company_category''
Check $city_name and $company_category. you have an extra `'` at the end
可以发布错误消息。找到解决方案会更容易。