帮帮我
错误讯息:
error query: "SELECT SQL_CALC_FOUND_ROWS *
FROM user WHERE gender='$gender'
DESC limit 15";
答案 0 :(得分:1)
问题在于这一行:
...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
答案 1 :(得分:1)
原则上,两个选项中的任何一个都应该有效:
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:反击字段名称是一个好习惯。