<p>
mysql> select user from user;
</p>
<p>
+-----------------+ | user | +-----------------+ | test1@localhost | | root | | backupuser | | root | | root | | root | | root | | test | | test2 | | root | +-----------------+ 10 rows in set (0.00 sec) mysql> mysql> select user from user group by user; +-----------------+ | user | +-----------------+ | backupuser | | root | | test | | test1@localhost | | test2 | +-----------------+ 5 rows in set (0.00 sec) mysql> select user,count(*) from user group by user; +-----------------+----------+ | user | count(*) | +-----------------+----------+ | backupuser | 1 | | root | 6 | | test | 1 | | test1@localhost | 1 | | test2 | 1 | +-----------------+----------+ 5 rows in set (0.00 sec) mysql> select user,count(*) from user group by user; +-----------------+----------+ | user | count(*) | +-----------------+----------+ | backupuser | 1 | | root | 6 | | test | 1 | | test1@localhost | 1 | | test2 | 1 | +-----------------+----------+ 5 rows in set (0.00 sec) mysql> select user,count(*) from user group by user; +-----------------+----------+ | user | count(*) | +-----------------+----------+ | backupuser | 1 | | root | 6 | | test | 1 | | test1@localhost | 1 | | test2 | 1 | +-----------------+----------+ 5 rows in set (0.00 sec) mysql> select user from user group by user; +-----------------+ | user | +-----------------+ | backupuser | | root | | test | | test1@localhost | | test2 | +-----------------+ 5 rows in set (0.00 sec) mysql> select user,host from user group by user; +-----------------+--------------+ | user | host | +-----------------+--------------+ | backupuser | 127.0.0.1 | | root | 10.10.20.136 | | test | localhost | | test1@localhost | % | | test2 | localhost | +-----------------+--------------+ 5 rows in set (0.00 sec) mysql>
select user,host,group_concat(host) from user group by user;
+-----------------+-----------+---------------------------------------------------------------------------+ | user | host | group_concat(host) | +-----------------+-----------+---------------------------------------------------------------------------+ | backupuser | 127.0.0.1 | 127.0.0.1 | | root | localhost | localhost,211.151.107.178,10.10.20.136,::1,127.0.0.1,test-Aspire-E1-571G | | test | localhost | localhost | | test1@localhost | % | % | | test2 | localhost | localhost | +-----------------+-----------+---------------------------------------------------------------------------+ 5 rows in set (0.00 sec) mysql> select user,host,group_concat(host) from user group by user with rollup; +-----------------+-----------+-----------------------------------------------------------------------------------------------------------+ | user | host | group_concat(host) | +-----------------+-----------+-----------------------------------------------------------------------------------------------------------+ | backupuser | 127.0.0.1 | 127.0.0.1 | | root | localhost | localhost,211.151.107.178,10.10.20.136,::1,127.0.0.1,test-Aspire-E1-571G | | test | localhost | localhost | | test1@localhost | % | % | | test2 | localhost | localhost | | NULL | localhost | 127.0.0.1,localhost,211.151.107.178,10.10.20.136,::1,127.0.0.1,test-Aspire-E1-571G,localhost,%,localhost | +-----------------+-----------+-----------------------------------------------------------------------------------------------------------+ 6 rows in set (0.00 sec) mysql>
</p>