您好,欢迎访问一九零五行业门户网

Php怎么展示一对多的关系

php如何展示一对多的关系?
需要展示的效果类似下图:
其中俱乐部一项可能有多个值.
而对应的表结构如下:
create table users(
  uid int(11) not null auto_increment,
  uname varchar(32),
  primary key (uid)
)
create table groups(
  gid int(11) not null auto_increment,
  gname varchar(32),
  primary key (gid)
)
create table user_group(
  uid int(11),
  gid int(11)
)
请问怎么样查询出并并用php展示如如图的效果?
------解决思路----------------------
select u.uname , group_concat(g.gname) from users u, user_group ug, groups g 
where u.uid=ug.uid and ug.gid=g.gid group by u.uid;
其它类似信息

推荐信息