我目前在表中有这样的数据:
id  |  type
------------
1   |  1
2   |  1
3   |  2
4   |  2
5   |  3
6   |  3
6   |  3
我需要显示这样的数据:
Type 1
--All type ones go here
Type 2
-- All type twos go here
Type 3
All type threes go here
我现在这样做的方式是使用两个单独的 sql 语句和循环。
select distinct type as type from table
while()
{
 select type from table where type = type;
 while()
 {
 }
}
有没有更好的方法来做到这一点并获得我想要的结果,或者使用两个循环是唯一的方法?