[英]Sql Selection not working with WHERE CLAUSE
我想用WHERE CLAUSE做一个sql选择,问题是当我定义WHERE CLAUSE,什么都没有返回时,我的代码有问题吗?
WHERE CLAUSE的变量$ id是一个整数
$request = $this->_db ->prepare('SELECT id, title, brand, content,price, DATE_FORMAT(addingDate, \'%d/%m/%Y à %Hh%imin%ss\') AS addingDateFr FROM product ORDER BY addingDateFr ASC LIMIT :start ,:end WHERE categoryId = :categoryId');
$request->bindValue(':start', $start, PDO::PARAM_INT);
$request->bindValue(':end', $end, PDO::PARAM_INT);
$request->bindValue(':categoryId', $id);
return $request;
问题只出现在THIS WHERE CLAUSE。 我得到一个空洞的结果。
谢谢,我需要帮助
爱德华
错误在于您的查询语法, WHERE
在ORDER BY
之前出现。 试试这个:
$request = $this->_db ->prepare('SELECT id, title, brand, content,price, DATE_FORMAT(addingDate, \'%d/%m/%Y à %Hh%imin%ss\') AS addingDateFr FROM product WHERE categoryId = :categoryId ORDER BY addingDateFr ASC LIMIT :start ,:end' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.