--我有一个类似于这样的表:
ID | Player1 | Player2 | Player3 | Player4 | Player5 | Player6 | Place
==============================================================================
1 | Greg | NULL | Mike | NULL | NULL | NULL | Rockford
2 | NULL | Lisa | NULL | JEFF | NULL | NULL | Peoria 我想要的输出是:
Place | Players
=====================
Rockford | Greg, Mike
Peoria | Lisa, Jeff我尝试了什么:
我尝试在SELECT语句中使用CONCAT,但这似乎是一种草率的做法。
是否有更好的方法来选择Player1、Player2等不为NULL的球员?
发布于 2017-05-02 02:51:19
你在找concat_ws
select place, concat_ws(',', player1, player2, player3, player4, player5, player6) as players
from your_table;https://stackoverflow.com/questions/43729285
复制相似问题