需求:
1 a
2 b
3 c
4 d
在資料庫中傳乙個 1,2,3過來 要得到 a,b,c這樣的結果
-- 函式如下:
-- i_str 表示傳進去的 字串 f_delimit 表示分隔符
-- 呼叫函式的辦法
select func_get_split_string('1,2,3',',');
注意:1. 遇到這樣的錯誤
this function has none of deterministic, no sql, or reads sql data in its de
解決辦法 執行 :set global log_bin_trust_function_creators=true;
2. 在函式中 select @變數 := 字段 from 表名 ;這樣的語句是不能通過的, 但是在過程裡面是可以的。
not allowed to return a result set from a function
mysql分割字串 mysql分割字串
專案有通過一批id去過濾結果的需求,因為這個id是從其他平台拉下來的excel,為了避免加引號逗號的麻煩,在mysql儲存過程裡面拼接。在此做個記錄。很多地方用得上。1.通過某個字元,分割字串的函式。輸入分別為f string 待分割字串 f delimiter 分割字元 f order 取的字串的...
mysql分割字串
一 今天寫東西用到資料庫分割字串,把 貼一下,留個腳印 二 主要部分如下 vpedoids 1,2,3 declare i int set i 1 if i 1 then select substring index vpedoids,i into temp else set temp substr...
mysql分割字串
專案有通過一批id去過濾結果的需求,因為這個id是從其他平台拉下來的excel,為了避免加引號逗號的麻煩,在mysql儲存過程裡面拼接。在此做個記錄。很多地方用得上。1.通過某個字元,分割字串的函式。輸入分別為f string 待分割字串 f delimiter 分割字元 f order 取的字串的...