Set
O(∩_∩)O ~, ?
:
mysql> select userlevel,username from users;
+-----------+----------+
| userlevel | username |
+-----------+----------+
| admin | cdliang |
| service | bobo |
| user | caocao |
| user | yongyong |
| service | zhouzhou |
+-----------+----------+
5 rows in set (0.00 sec)
:
1.distinct
mysql> select count(distinct userlevel) from users;
+----------+
| |
+----------+
| 3 |
+----------+
1 row in set (0.00 sec)
2.
mysql> select count(*) from (select distinct userlevel from users) t;
+----------+
| |
+----------+
| 3 |
+----------+
1 row in set (0.00 sec)