我试图按日期订购表格,但收到此错误。
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近'WHERE
user_name
='felipe'限制0,5'在第1行
如果我删除了ORDER BY file_time
,它可以正常运行..
有什么想法吗?
mysql_query("SELECT * FROM files ORDER BY `file_time` WHERE `user_name` = '{$_SESSION['username']}' LIMIT $start, $per_page")
答案 0 :(得分:3)
mysql_query("SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` LIMIT $start, $per_page")
答案 1 :(得分:2)
您的查询顺序是混合的:
mysql_query("SELECT * FROM files ORDER BY `file_time` WHERE `user_name` = '{$_SESSION['username']}' LIMIT $start, $per_page")
应该是
mysql_query("SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` LIMIT $start, $per_page")
答案 2 :(得分:2)
我相信您的问题是您对ORDER BY的定位。试试这个:
SELECT * FROM files WHERE `user_name` = '{$_SESSION['username']}' ORDER BY `file_time` LIMIT $start, $per_page