gpt4 book ai didi

mysql - mysql 中的 Group by 子句

转载 作者:太空宇宙 更新时间:2023-11-03 10:49:14 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com