MySQL:使用单行查询多列的性能
我的表格简化了这样的事情......
Table Categories
cat_id | cat_name
-------------------
1 | Baseball
2 | Hockey
3 | Football
Table Day
day_id | day_name
--------------------
1 | Friday
2 | Saturday
3 | Sunday
Table Day_Categories
day_id | cat_id
-------------------
1 | 1
1 | 2
2 | 2
2 | 3
3 | 1
3 | 2
3 | 3
我希望我的结果数据看起来像这样......
"Friday","Baseball, Hockey"
"Saturday","Hockey, Football"
"Sunday", "Baseball, Hockey, Football"
它不一定需要采用三行格式。我只需要相同的结果数据。
从大量数据的性能角度来看,实现这一结果的最佳方法是什么?
My tables simplified something like this..
Table Categories
cat_id | cat_name
-------------------
1 | Baseball
2 | Hockey
3 | Football
Table Day
day_id | day_name
--------------------
1 | Friday
2 | Saturday
3 | Sunday
Table Day_Categories
day_id | cat_id
-------------------
1 | 1
1 | 2
2 | 2
2 | 3
3 | 1
3 | 2
3 | 3
And I want my resulting data to look something like this...
"Friday","Baseball, Hockey"
"Saturday","Hockey, Football"
"Sunday", "Baseball, Hockey, Football"
It doesn't necessary need to be in three row format. I just need the same resulting data.
From a performance prospective with lots of data what's likely the best way to achieve this result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请试试这个
Please try this one