-2

帮我

错误信息:

error query: "SELECT SQL_CALC_FOUND_ROWS * 
               FROM user WHERE gender='$gender'
               DESC limit 15";
4

2 回答 2

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
于 2013-04-14T05:46:42.450 回答
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:反引号是一个好习惯。

于 2013-04-14T05:55:35.553 回答