PHP SQL查询ORDER by - Syntax-Mistake?

时间:2016-07-13 11:58:30

标签: mysql sql

我想通过id desc订购以下查询(它是" check_todo" -table中的一列)。有谁能够帮我? :)

$todo_query = mysqli_query($db, "SELECT * FROM check_todo WHERE id=".$row2->todo." ORDER by id DESC");
while($row3 = mysqli_fetch_object($todo_query))
    {

它没有重复,也不是因为保留字。它没有与" id" oder"占位符" (check_todo中的两列)要么......

1 个答案:

答案 0 :(得分:0)

TYPE is a reserved keyword in MySQL
在它周围添加反引号:

$todo_query = mysqli_query($db, "SELECT * FROM check_todo WHERE id=".$row2->todo . 
      " ORDER by `type` ASC");