我的数据库中有一个名为“students”的表,其中包含以下列 (student_id, student_name, year_of_birth).和年份数组 我尝试进行一个查询,以在(年)数组中获取每年的 10 个 student_id。
我会写
SELECT student_id FROM `students` WHERE year_of_birth=1950 LIMIT 10;
SELECT student_id FROM `students` WHERE year_of_birth=1951 LIMIT 10;
SELECT student_id FROM `students` WHERE year_of_birth=1952 LIMIT 10;
SELECT student_id FROM `students` WHERE year_of_birth=1953 LIMIT 10;
(and so on)
但是那会很费时间 还有其他选择吗 谢谢
最佳答案
“在 MySQL 中为一组选择 N 行”:http://explainextended.com/2009/03/06/advanced-row-sampling/
关于php - mysql 一条sql语句中的多个限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2081323/