Php SQL Distinct未删除重复的元素。为什么?
我正在使用以下查询:Php SQL Distinct未删除重复的元素。为什么?,php,sql,wordpress,distinct,Php,Sql,Wordpress,Distinct,我正在使用以下查询: $cities = $wpdb->get_results( "select distinct ID , post_title from $wpdb->posts where post_type = 'place' and post_parent = $state_id order by post_title ", ARRAY_A ); 但重复的元素不会被删除。为什么? 以下是全部用法: <label for="veneue_finder_city_sel
$cities = $wpdb->get_results( "select distinct ID , post_title from $wpdb->posts where post_type = 'place' and post_parent = $state_id order by post_title ", ARRAY_A );
但重复的元素不会被删除。为什么?
以下是全部用法:
<label for="veneue_finder_city_select">Cityyyyyyyyyyyyyyyyyyyy</label>
<select id="veneue_finder_city_select" name="city_id">
<option value="">Any</option>
<?php
if( !empty($state_id) ) {
$states = array();
$cities = $wpdb->get_results( "select distinct ID , post_title from $wpdb->posts where post_type = 'place' and post_parent = $state_id order by post_title ", ARRAY_A );
foreach( $cities as $city ):
?>
<option value="<?php echo $city['ID']; ?>" <?php selected($city['ID'], $city_id) ?>><?php echo $city['post_title']; ?></option>
<?php endforeach;
}?>
</select>
cityyyyyyyyyyyyyyyyyy
任何
>
你能举例说明你的结果吗?哪个部分重复?因为ID;)每个帖子都有不同的ID-我说的对吗?编辑你的问题,提供样本数据和期望的结果。你可能只是不明白select distinct是做什么的。我复制了一些城镇,比如:柏林等。@RumenPanchev:有不同的ID
s?