大家好,如果包含在另一个表中,我应该实现不显示某个值的可能性,如本例所示:仅显示未与客户关联的工厂的某些参数
"SELECT * FROM store_locator WHERE store_locator.id NOT IN (SELECT impianto_id_campagna FROM campagne_cliente);
但在此查询中:
function get_stores_list2($criteria=array()) {
$id = $criteria['id'];
$lat = $criteria['lat'];
$lng = $criteria['lng'];
$page_number = $criteria['page_number'];
$nb_display = $criteria['nb_display'];
$distance_unit = $criteria['distance_unit'];
$max_distance = $criteria['max_distance'];
$category_id = $criteria['category_id'];
$table_name = $GLOBALS['db_table_name'];
$start = ($page_number*$nb_display)-$nb_display;
$s1 = new MySqlTable();
if($distance_unit=='miles') $distance_unit='3959'; //miles
else $distance_unit='6371'; //km
$sql = "SELECT *,
( $distance_unit * acos( cos( radians('".$s1->escape($lat)."') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('".$s1->escape($lng)."') ) + sin( radians('".$s1->escape($lat)."') ) * sin( radians( lat ) ) ) ) AS distance
FROM ".$table_name."
WHERE 1";
if($id!='') $sql .= " AND id='".$s1->escape($id)."'";
if($category_id!='') $sql .= " AND category_id='".$s1->escape($category_id)."'";
if($max_distance!='') $sql .= " HAVING distance<='".$s1->escape($max_distance)."'";
if($lat!='' && $lng!='') $sql .= " ORDER BY distance";
else $sql .= " ORDER BY name";
if($nb_display>0) $sql .= " LIMIT $start, $nb_display";
//echo $sql.'<br>';
$locations = $s1->customQuery($sql);
return $sql;
}
暂无答案!
目前还没有任何答案,快来回答吧!