帮我
错误信息:
error query: "SELECT SQL_CALC_FOUND_ROWS *
FROM user WHERE gender='$gender'
DESC limit 15";
问题出在这一行的某个地方:
...WHERE gender='$gender' DESC limit 15
如您所见,您没有ORDER BY
子句,但您使用了DESC
关键字。尝试通过删除关键字来修复它DESC
...WHERE gender='$gender' limit 15
或添加ORDER BY
子句
...WHERE gender='$gender' ORDER BY col_name DESC limit 15
原则上,这两个选项中的任何一个都应该起作用:
SELECT SQL_CALC_FOUND_ROWS * FROM `user` WHERE `gender`='$gender' LIMIT 15;
或不运行查询SQL_CALC_FOUND_ROWS
并执行单独的SELECT COUNT(*)
查询
SELECT * FROM `user` WHERE `gender`='$gender' LIMIT 10;
SELECT COUNT(*) FROM `user` WHERE `gender`='$gender';
PS:反引号是一个好习惯。