大家好,又见面了,我是你们的朋友全栈君。
目标 将 rull字段值的0.1g*14 粒/1.5mg*30 片/100ml(氨甲环酸0.5g:氯化钠0.84g)*1 瓶 中的mg/g/ml开头的数字取出设置到另外一个字段上去
SELECT id from sheet2 where rull like ‘%ml%’ ;SELECT id,count, LEFT(rull,LOCATE(‘g’,rull)-1) from sheet2 where rull like ‘%g%’ ;
SELECT id,count, LEFT(rull,LOCATE(‘mg’,rull)-1) from sheet2 where rull like ‘%mg%’ and id not in (SELECT c.id from (
SELECT id from sheet2 where rull like ‘%ml%’ ) c )
update sheet2 set count=LEFT(rull,LOCATE(‘mg’,rull)-1) where rull like ‘%mg%’ and id not in (SELECT c.id from ( SELECT id from sheet2 where rull like ‘%ml%’ ) c);
update sheet2 set count=LEFT(rull,LOCATE(‘mg’,rull)-1) where rull like ‘%mg%’ and id not in (SELECT c.id from ( SELECT id from sheet2 where rull like ‘%ml%’ ) c);
update sheet2 set count=LEFT(rull,LOCATE(‘ml’,rull)-1) where rull like ‘%ml%’ ;
substring_index(str,delim,count),str是要截取的字符串,delim是截取的字段 count是从哪里开始截取(为0则是左边第0个开始,1位左边开始第一个选取左边的,-1从右边第一个开始选取右边的
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/137963.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...