如題,用到了兩個函數locate和substringide
locate('要查詢的字符','字符所在的字符串') eg:locate('_','test_cd'); substring('被截取的字符串',開始下標,結束下標) eg:substring('test_cd',1,4)
兩個函數能夠合併使用函數
SELECT SUBSTRING('test_cd',1,LOCATE('_','test_cd')-1);
結果爲spa