substring_index() 函數 字符串截取
表達式:substring_index(column,str,count)
釋義:截取字符串column,str出現從前往后數第count次,之前的所有字符
示例語句:SELECT substring_index(‘www.baidu.com’,‘.’,2)
結果展示: www.baidu
表達式:substring_index(column,str,-count)
釋義:截取字符串column,str出現從后往前數第count次,之后的所有字符
示例語句:SELECT substring_index(‘www.baidu.com’,‘.’,-2)
結果展示:baidu.com
參考大神博客
replace() 字符串替換
replace(要操作的字符串,要替換操作字符串的字符,替換后的字符)
eg: 將 字符串 ,0121 中的逗號去掉
select replace(',0121',',','')
結果 : 0121
ROUND() 函數 保留多少位小數
eg 12.3456 保留兩位小數
SELECT ROUND(12.3456 , 2) --12.35
參考大神博客
locate() 函數 判斷某個字段屬性值是否包含某個字符串
eg 判斷 open_with 字段 屬性值是否包含雙開 >0 包含 <=0 不包含
locate('雙開',open_with)
concat() 函數 字段屬性值連接文章來源:http://www.zghlxwxcb.cn/news/detail-638381.html
eg select concat('1','0','你是')
10你是
case when then else
CASE SCORE WHEN 'A' THEN '優(yōu)' ELSE '不及格' END
CASE SCORE WHEN 'B' THEN '良' ELSE '不及格' END
CASE SCORE WHEN 'C' THEN '中' ELSE '不及格' END
(case WHEN cloth_track_type <> 3 and locate('左右拼接',work_procedure_name) > 0 then
substring_index(replace(replace(substring_index(work_fee_rule_desc,'計價規(guī)則:',-1),',',''),' ',''),'=',-1)
else ''
end) as pinjie_cs,
參考大神博客文章來源地址http://www.zghlxwxcb.cn/news/detail-638381.html
到了這里,關于sql 語句 字段字符串操作的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!