繁体   English   中英

在mysql中排序和限制条件

[英]order by and limit condition in mysql

$ sqlsl =“从newmessage中选择*,其中sendto ='”。$ userid。“'按inboxid限制10”

请帮我

上表按ASC顺序检索我的badabase中的前10行。 我的数据库包含100条记录。 我只需要按降序排列的前10条记录

请试试

"$sqlsl = "select * from newmessage where sendto='".$userid."'
order by inboxid  DESC limit 10";

请参阅MySQL文档中的页面。

$sqlsl = "select * from newmessage where sendto='".$userid."' order by inboxid DESC limit 10";

要按降序获取记录,应将DESC关键字添加到order by子句中:

$sqlsl = "select * from newmessage 
where sendto='".$userid."' 
order by inboxid desc 
limit 10";

用这个

选择* from(从*新消息中选择*,其中sendto ='“。$ userid。”'按inboxid限制10排序)作为message_id由message_id desc排序

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM