if(isset($_POST['search'])){
$mls=$_POST['mls_number'];
$sql = "SELECT * FROM listing_master_residential
, listing_master_condo
, listing_master_commercial
INNER JOIN listing_master_residential AS res ON res.Ml_num=Ml_num
INNER JOIN listing_master_condo AS con ON con.Ml_num=Ml_num
INNER JOIN listing_master_commercial AS com ON com.Ml_num=Ml_num
WHERE Ml_num='$mls'";
$result = $wpdb->get_results($sql) or die(mysql_error());
foreach( $result as $row){
echo $row->Lot_code."<br/>";
echo $row->Ml_num."<br/>";
echo $row->Acres;
echo $row->Addr."<br/>";
echo $row->Bath_tot;
echo $row->Br;
echo $row->Br_plus;
}
}
}
请检查我的代码,他们会显示错误代码
where子句中的列'Ml_num'是不明确的
提前谢谢你 请帮帮我..我哪里错了 ?
答案 0 :(得分:0)
试试这个
$sql = "SELECT * FROM listing_master_residential AS res
INNER JOIN listing_master_condo AS con ON con.Ml_num=res.Ml_num
INNER JOIN listing_master_commercial AS com ON com.Ml_num=con.Ml_num
WHERE res.Ml_num='$mls'";
答案 1 :(得分:0)
$ sql =“SELECT * FROM listing_master_residential
,listing_master_condo
,listing_master_commercial
INNER JOIN listing_master_residential AS res ON res.Ml_num = Ml_num
INNER JOIN listing_master_condo AS con ON con.Ml_num = Ml_num
INNER JOIN listing_master_commercial AS com ON com.Ml_num = Ml_num
在哪里 Ml_num ='$ mls'“;
这里有几个错误:
列Ml_num是恶意的,因为MySQL告诉你(你应该在你使用它的每个地方使用table_name.Ml_num。
$sql = "SELECT * FROM listing_master_residential AS lmr
INNER JOIN listing_master_residential AS res ON res.Ml_num=lmr.Ml_num
INNER JOIN listing_master_condo AS con ON con.Ml_num=lmr.Ml_num
INNER JOIN listing_master_commercial AS com ON com.Ml_num=lmr.Ml_num
WHERE lmr.Ml_num='$mls'";
我认为这应该有用。