SELECT * FROM table name
where property_type='residential' and lp_dol BETWEEN '1' and '450000'
and cross_st='city name'
我想搜索屬性值,如1至450,000之間的價格在像任何城市名稱的城市。MySQL查詢返回不正確的結果
但現在表示的範圍(1 - 450000)的值與上述價格範圍等價格-1000390一些結果,(一些結果不是所有)
<?php $mydata = array();
if($protype_se!="" && $protype_se!="0") {
$mydata[] = "property_type='$protype_se'";
}
if($protype_city !="") {
$mydata[] = "cross_st='$protype_city'";
}
if($protype_from !="" && $protype_to !="") {
$mydata[] = "lp_dol BETWEEN $protype_from and $protype_to";
}elseif($protype_from =="" && $protype_to !=""){
$mydata[] = "lp_dol BETWEEN $protype_cust and $protype_to";
}
if($protype_bed !="") {
$mydata[] = "br >='$protype_bed'";
}if($protype_baths !="") {
$mydata[] = "bath_tot >='$protype_baths'";
}
if($protype_pstyle !=""&& $protype_pstyle !="Att/Row/Twnhouse") {
$mydata[] = "style='$protype_pstyle'";
}elseif($protype_pstyle !="" && $protype_pstyle =="Att/Row/Twnhouse"){
$mydata[] = "town='$protype_pstyle'";
}
if($protype_gtype !="") {
$mydata[] = "gar_type='$protype_gtype'";
}
if($protype_pool !="") {
$mydata[] = "pool='$protype_pool'";
}
if($protype_fplace !="") {
$mydata[] = "fpl_num='$protype_fplace'";
}
if($protype_for !="") {
$mydata[] = "s_r='$protype_for'";
}
if($protype_gmin!="" && $protype_gmax!="") {
$mydata[] = "gross_texes BETWEEN '$protype_gmin' and '$protype_gmax'";
}
if($protype_lmin!="" && $protype_lmax!="") {
$mydata[] = "land_size BETWEEN '$protype_lmin' and '$protype_lmax'";
}
if($protype_pmin!="" && $protype_pmax!="") {
$mydata[] = "price_sqft BETWEEN '$protype_pmin' and '$protype_pmax'";
}if($protype_se!="" && $protype_se=="0") {
$mydata[] = "lp_dol BETWEEN '$protype_cust' and '$protype_end'";
}
$quer = "SELECT * FROM listing_featured_property";
$sql = $quer;
if (count($mydata) > 0) {
$sql .= " where " . implode(' and ', $mydata)." order by lp_dol DESC LIMIT $offset, $limit";
}
?>
請編輯您的問題並添加表格定義,如'SHOW CREATE TABLE'所示。 – VolkerK
加上關於php和mysql的示例數據和版本信息。 – VolkerK
請稍候我在這裏更新我的php代碼... – avktech