mysql - mysql 中的 Group by 子句

标签 mysql

我正在努力对我的数据进行分组,目前我有这个

enter image description here

如果我通过名称(第 1 列)对结果进行分组,我的数据将变为

enter image description here

我这是什么

enter image description here

如您所见,我想将我的列 1 分组,其中名称(列 2)相同,不知道如何实现。

PS:我在我的 6 个表上查询的结果是我的查询

select a.name, b.name, d.price, e.id from tbl1 a, tbl2 b, tbl3 c,
tbl4 d, tbl5 e, tbl6 f
where a.id=c.patron_id and b.id=c.cinema_id and d.movies_schedule_list_id=e.id 
and e.movies_schedule_id=f.id and f.cinema_id=b.id and f.movie_date = '2014/10/31'
order by b.name;

我试着把

group by a.name having b.name= ?? 

但我不知道在哪里可以等于 b.name。请帮助我,在此先感谢

最佳答案

只需按照标准将两个字段组合为您的组

group by a.name, b.name

关于mysql - mysql 中的 Group by 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26770764/

相关文章:

mysql - (MySQL) 存储过程 - 遍历结果

mysql 将另一个表的行作为查询中的列连接起来

php - 图片无法加载

php - 无法使用 Jquery 从行表获取 Post 值 ID 到 PHP

php - MySQLi 从 table1 查询并将详细信息更新到 table2

mysql - 查询返回有关嵌套元素的数据

mysql - SQL 语句出现错误

java - Hibernate - 实体 - 数据库保存

mysql - sql group_concat 和子查询

mysql - 带有 INNER JOIN 和子查询的 WHERE 子句