2015-03-02 13 views

回答

0

您可以使用substring_index()。以你的问题为例:

select substring_index(hashtag, ',', 1) as tag1, 
     (case when hashtag like '%,%' 
      then substring_index(substring_index(hashtag, ',', 2), ',', -1) 
     end) as tag2, 
     (case when hashtag like '%,%,%' 
      then substring_index(hashtag, ',', -1) 
     end) as tag3 
. . .