我的mysql过滤器有问题。如果用户有空字段,则查询不起作用。我该如何解决这个问题,我尝试过发送' NULL'在类型中如果未选择类型,但这也不起作用。
$STH = $DBH->query("
SELECT *
WHERE store ='$type' and sdn='$status' and price>='$price_s' and price<='$price_e' ORDER BY id DESC LIMIT $setlimit");
$STH = $DBH->query("
SELECT *
WHERE store ='$type' and sdn='$status' and price>='$price_s' and price<='$price_e' ORDER BY id DESC LIMIT $setlimit");
答案 0 :(得分:0)
似乎缺少来自,例如如果表是销售,请尝试
$STH = $DBH->query("
SELECT * from sales
WHERE store='$type' and sdn='$status' and price>='$price_s' and price<='$price_e'
ORDER BY id DESC LIMIT $setlimit");
$STH = $DBH->query("
SELECT * from sales
WHERE store='$type' and sdn='$status' and price>='$price_s' and price<='$price_e'
ORDER BY id DESC LIMIT $setlimit");
答案 1 :(得分:0)
您错过了FROM your_table
指令
$STH = $DBH->query("
SELECT *
FROM table
WHERE store ='$type' and sdn='$status' and price>='$price_s' and price<='$price_e' ORDER BY id DESC LIMIT $setlimit");
只需输入表格的名称即可(如果字段存在)