mysql> select * from t1;
+----+------+
| no | name |
+----+------+
| 1 | a |
| 1 | b |
| 1 | c |
| 1 | d |
| 2 | a |
| 2 | b |
| 2 | c |
| 3 | d |
+----+------+
8 rows in set (0.16 sec)
mysql> select no,group_concat(name separator ' ') from t1 group by no;
+----+----------------------------------+
| no | group_concat(name separator ' ') |
+----+----------------------------------+
| 1 | a b c d |
| 2 | a b c |
| 3 | d |
+----+----------------------------------+
3 rows in set (1.36 sec)
D:\mysql50\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 5.0.13-rc-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
mysql> show tables from test;
+----------------+
| Tables_in_test |
+----------------+
| t |
| tmp1 |
+----------------+
2 rows in set (2.51 sec)
mysql> desc test.t;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| s1 | int(11) | NO | PRI | 0 | |
+-------+---------+------+-----+---------+-------+
1 row in set (2.72 sec)
mysql> select @@version;
+--------------+
| @@version |
+--------------+
| 5.0.13-rc-nt |
+--------------+
1 row in set (0.23 sec)
你登录后,是不是出现一个下面命令提示符呀?
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23 to server version: 4.1.12-nt-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.