在mysql数据库中的嵌套条件中选择多行

时间:2015-11-28 06:32:09

标签: mysql rows limits levels

在嵌套条件中选择多行,在mysql数据库中选择嵌套限制

实际上我有一张表:

id  name   levels 
1   Red          1
2   Red Light    1
3   Green        2
4   Green Light  2
5   Blue         3
6   Blue Light   3
7   Blue Dark    3

I want fetch any rows according to levels with any limits Like: 
From Level-1 = 1 row
From Level-2 = 2 row
From Level-3 = 2 row
 total rows are 5 according to levels.
Any one know about single query is possible?
 or
three foreach loop will be implement? 

0 个答案:

没有答案