大家好,我应该实现以下可能性:如果包含在另一个表中,则不显示特定值,在这种情况下:仅向某些数据显示未与客户相关联的工厂
"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;
}