我有一个问题,我试图建立,以便我可以过滤汽车品牌。但是,如果存在某个会话变量,它将要求额外的部分添加到查询中,这基本上将结果限制到登录的分支。以下是问题:
$query_AUCTION = "SELECT *
FROM at_auction AS a
JOIN at_brands AS b ON a.aCarBrandID = b.bid
ORDER BY b.brand $orderx";
... 现在可以了,但我在哪里可以添加:
"WHERE bid = '{$bid}'"? ...or a... "AND bid = '{$bid}'";
它会带来一个错误。
最佳答案
在您的订单前插入where子句
$query_AUCTION = "SELECT * FROM at_auction AS a JOIN at_brands AS b ON a.aCarBrandID = b.bid WHERE bid = '{$bid}' ORDER BY b.brand $orderx";
关于php - MySQL查询无法正常工作的PHP,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6655817/