为此,请使用GROUP_CONCAT()。让我们首先创建一个表-
mysql> create table DemoTable1355 -> ( -> Location text -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1355 values('E:'); mysql> insert into DemoTable1355 values('AllPrograms'); mysql> insert into DemoTable1355 values('ChatApplicationInJava'); mysql> insert into DemoTable1355 values('MainFolder');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1355;
这将产生以下输出-
+-----------------------+ | Location | +-----------------------+ | E: | | AllPrograms | | ChatApplicationInJava | | MainFolder | +-----------------------+ 4 rows in set (0.00 sec)
这是返回一行中所有项目的查询-
mysql> select group_concat(Location separator '/') from DemoTable1355;
这将产生以下输出-
+-------------------------------------------------+ | group_concat(Location separator '/') | +-------------------------------------------------+ | E:/AllPrograms/ChatApplicationInJava/MainFolder | +-------------------------------------------------+ 1 row in set (0.00 sec)