mysql 按指定字符拆分 查询

------------恢复内容开始------------

eg:有个value表 val列如下:

 

 

 

   

SELECT * from (SELECT id,SUBSTRING_INDEX(val,'|',1) as va1,
SUBSTRING_INDEX(val,'|',-1) as va2 from `value` )a where id=1

结果:

SELECT * from (SELECT id,SUBSTRING_INDEX(val,'|',1) as t1,

SUBSTRING_INDEX(SUBSTRING_INDEX(val,'|',2),'|',-1) as t2,
SUBSTRING_INDEX(SUBSTRING_INDEX(val,'|',3),'|',-1) as t3,
SUBSTRING_INDEX(val,'|',-1) as t4 from `value` )a where id=2;

 

 

posted on 2020-11-02 15:06  可乐冒泡泡丶  阅读(1335)  评论(0编辑  收藏  举报