dkfr.net
当前位置:首页 >> mysql 字段按逗号拆分 >>

mysql 字段按逗号拆分

SELECT a.aid AS '序号', a.`主管领导`, GROUP_CONCAT(b.`姓名`) AS `主管领导姓名` FROM a LEFT JOIN b on FIND_IN_SET(b.id , a.`主管领导`) GROUP BY a.aid ORDER BY a.aid ASC

select a.*,b.* from a left join b on find_in_set(b.id,a.zd1)

可以用split()方法,就是专门分割字符串的,比如说: city.split(",");就是将city对象用“,”分开,返回的是数组

拆分以逗号隔开的字符串,这是高级语言来处理的吧,数据库主要是存储数据的,比如php就可以这样实现: $string = '1,2,3,4,5'; $array = explode(',',$string); 之后就得出一个数组,$array(1,2,3,4,5);

select ID,group_concat(NAME) as NAME from table group by ID; select ID,group_concat(NAME SEPARATOR ';') as NAME from a group by ID;

$ret=explode(',',$data); print_r($ret);

MySQL分割字符串应该如何实现呢?下面就为您介绍MySQL分割字符串的实现方法步骤,希望可以让您对MySQL分割字符串有更多的了解。 例如:update `edw_video` set company = substring(keyword,1,length(SUBSTRING_INDEX(keyword,",",1))) 名称:SP...

? 首先我们建立一张带有逗号分隔的字符串。 CREATE TABLE test(id int(6) NOT NULL AUTO_INCREMENT,PRIMARY KEY (id),pname VARCHAR(20) NOT NULL,pnum VARCHAR(50) NOT NULL); 然后插入带有逗号分隔的测试数据 INSERT INTO test(pname,pnum) VA...

没错啊,你想做什么

SQL:select concat("'",replace('1234aff,afd,defg,d',",","','"),"'") 处理步骤: 将原字符串中的,替换为',' 即replace('1234aff,afd,defg,d',",","','") 在替换后的字符串首位添加' concat(str1,str2)

网站首页 | 网站地图
All rights reserved Powered by www.dkfr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com