Home  >  Article  >  Backend Development  >  问个关于查询的有关问题

问个关于查询的有关问题

WBOY
WBOYOriginal
2016-06-13 12:48:57801browse

问个关于查询的问题
我两张表 
表a        id  姓名  班级编号
表b         班级编号   班级中文名称



在php中,我想要这样显示

软件班
  张三 李四 .....

绘画班  

   王五 ........


请问 在php中怎么体现啊,另外我是用的smarty。
 

php
------解决方案--------------------
select a.班级编号,b.班级中文名称 , group_concat(a.姓名) as name_group from 表a a left join 表b b on a.班级编号=b.班级编号 group by a.班级编号

这样查询出来了就容易了
------解决方案--------------------
关联查询出来后,用数组处理...
------解决方案--------------------
php array 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn