开发者

mysql join 2 columns to order by

开发者 https://www.devze.com 2023-04-12 12:32 出处:网络
Having a real struggle with something. I have a list of fixtures that have the following: hometeam, awayteam, date, time, season, competition.

Having a real struggle with something. I have a list of fixtures that have the following:

hometeam, awayteam, date, time, season, competition.

I want to be able to join/group hometeam and awayteam so I can then group my results by this. So basicall开发者_运维技巧y I would only get one fixture per team. I obviously cant do this until I have somehow joined hometeam and away team as one column.

Any ideas how I would do this?


Try using the CONCAT() function:

SELECT CONCAT(hometeam, '-', awayteam) as fixture
     , date, time, season, competition
  FROM teams
 GROUP BY fixture
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号