我有一张这样的 table
id student teacher
10 a b
11 c b
12 d c
13 e b
学生“e”是老师为“b”的第三个学生。 如何通过一个查询得到这个?
最佳答案
你可以这样做:
SELECT * FROM (
SELECT @row := @row + 1 as row, t.* FROM student_table t, (SELECT @row := 0) r where t.teacher ='b'
) s where student = 'e'
关于mysql - 如何获取有条件的行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9093093/