阿尔法分页
我正在尝试在 MySQL 数据库中实现基于姓氏的分页。这些条目保存为“名字姓氏”,我想根据姓氏的第一个字母显示结果,如果该字母有很多结果,则将该列表拆分为数字页面。如有任何帮助,我们将不胜感激!
I am attempting to implement pagination based on the surname in a MySQL database. The entries are saved as "Firstname Lastname" and I would like to display the results based on the first letter of the surname, and if there are a lot of results for that letter, to split that list up into numerical pages. Any help at all is appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你说,
是的,不幸的是它在一个单独的列中。
这将使执行你所要求的操作变得困难且容易出错。毕竟,暂时远离真正的 SQL 代码,您将如何指定识别姓氏开头的规则呢?你说“第一个字后面都是姓”吗?
Cathy Anne Phillips
打破了你的规则。你说“只有最后一个字是姓氏”吗?塞缪尔·里夫斯·蒙哥马利
打破了它。您无法编写一个好的算法来识别名字的结束位置和姓氏的开始位置。如果要执行此操作,第一步是更改数据库表格式,以便姓氏和名字位于不同的列中。
You say,
And yes unfortunately it's in a single column.
This is going to make it both difficult and error-prone to do what you're asking for. After all, keeping away from real SQL code for the moment, how are you going to specify the rule for how to identify the start of the surname?Do you say "everything after the first word is the surname"?
Cathy Anne Phillips
breaks your rule. Do you say "only the last word is the surname"?Samuel Reeves Montgomery
breaks it. You can't write a good algorithm to recognise where the given name ends and the surname begins.If you want to do this, the first step is to change the database table format so that surname and firstname are in different columns.