php ORDER BY日期似乎不起作用

时间:2013-09-27 14:15:52

标签: php mysql

我只想显示折扣最新的图书。 Dealstart和Dealend代表了窗口。但是我搞砸了什么。

$sqlCommand = "SELECT id,bookcover FROM booklist WHERE category1='$bookid' OR category2='$bookid' OR category3='$bookid' AND dealstart >= CURDATE() AND dealend is >= CURDATE()";

2 个答案:

答案 0 :(得分:0)

看起来SQL语句中存在语法错误,删除“是”:

lCommand = "SELECT id,bookcover FROM booklist WHERE category1='$bookid' OR category2='$bookid' OR category3='$bookid' AND dealstart >= CURDATE() AND dealend >= CURDATE()";

如果查询仍无效,请回显“lCommand”并查看其产生的内容,然后尝试针对您的数据库运行该查询。

答案 1 :(得分:0)

喜欢这个吗?

$sqlCommand = "SELECT
                   id,
                   bookcover
               FROM
                   booklist
               WHERE
                   category1='$bookid' OR
                   category2='$bookid' OR
                   category3='$bookid' AND
                   dealstart >= CURDATE() AND
                   dealend >= CURDATE()
               ORDER BY
                   dealend DESC";