gpt4 book ai didi

mysql - 如何根据结果集中的值限制MySQL结果?

转载 作者:行者123 更新时间:2023-11-29 08:53:02 25 4
gpt4 key购买 nike

我正在创建一个 PHP 脚本,用于维护用户信息、注册新用户以及登录安全页面。为此,我有一个 MySQL 表user,它存储有关用户的所有信息。 用户表有不同的字段,如用户 ID、用户名、用户组 ID、电子邮件哈希值、国家/地区等。

在我的脚本中,我想从每个 usergroup_id 中获取 10 个用户。
SQL 查询是什么?

最佳答案

您可以使用LIMIT子句。

示例:

SELECT * FROM `your_table` LIMIT 5, 5 

这将显示记录 6、7、8、9 和 10。

Limit is used to limit your MySQL query results to those that fall within a specified range. You can use it to show the first X number of results, or to show a range from X - Y results. It is phrased as Limit X, Y and included at the end of your query. X is the starting point (remember the first record is 0) and Y is the duration (how many records to display).

关于mysql - 如何根据结果集中的值限制MySQL结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10663913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com