前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mysql截取中文字符_mysql截取字符串函数-Go语言中文社区

mysql截取中文字符_mysql截取字符串函数-Go语言中文社区

作者头像
全栈程序员站长
发布2022-08-23 12:26:06
1.5K0
发布2022-08-23 12:26:06
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

目标 将 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%’ ;

88221b83a9a7660f5b85072f775c2095.png
88221b83a9a7660f5b85072f775c2095.png

substring_index(str,delim,count),str是要截取的字符串,delim是截取的字段 count是从哪里开始截取(为0则是左边第0个开始,1位左边开始第一个选取左边的,-1从右边第一个开始选取右边的

75a135ee22be7b3c531fcf3b30fb7a4e.png
75a135ee22be7b3c531fcf3b30fb7a4e.png
23ca875b05efe2b1c6c56722bc429dd6.png
23ca875b05efe2b1c6c56722bc429dd6.png

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/137963.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年5月5,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档