在PHP5 MySQL中按升序检索数据

时间:2019-05-31 13:16:33

标签: php mysql

if($limit== '400'){
    $sql="SELECT * FROM report ORDER BY reportID ASC LIMIT $limit WHERE userID='$reportID'";}

"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE userID='147'' at line 1"

任何可以帮助我的人。我是php编程语言的初学者。

1 个答案:

答案 0 :(得分:2)

Where子句应放在Order By

之前

尝试一下:

if($limit== '400'){
    $sql="SELECT * FROM report WHERE userID='$reportID' ORDER BY reportID ASC LIMIT $limit";
}