oracle分割字符串split php如何用逗號(hào)把字符串分割為數(shù)組并把數(shù)組分別寫入數(shù)據(jù)庫(kù)?
php如何用逗號(hào)把字符串分割為數(shù)組并把數(shù)組分別寫入數(shù)據(jù)庫(kù)?分割字符串可以用explode函數(shù)$str = "1,2,3,4,5,6"$arr = explode(",",$str)foreach($a
php如何用逗號(hào)把字符串分割為數(shù)組并把數(shù)組分別寫入數(shù)據(jù)庫(kù)?
分割字符串可以用explode函數(shù)$str = "1,2,3,4,5,6"$arr = explode(",",$str)foreach($arr as $a){ #插入數(shù)據(jù)庫(kù)就可以}
MySQL截取和拆分字符串函數(shù)用法示例?
MySQL字符串函數(shù)substring:字符串截取
MySQL 字符串截取函數(shù):left(), right(), substring(), substring_index()。還有 mid(), substr()。其中,mid(), substr() 等價(jià)于 substring() 函數(shù),substring() 的功能非常強(qiáng)大和靈活。
1. 字符串截?。簂eft(str, length)
mysql> select left("example.com", 3)
-------------------------
| left("example.com", 3) |
-------------------------
| exa |
-------------------------
2. 字符串截?。簉ight(str, length)
mysql> select right("example.com", 3)
--------------------------
| right("example.com", 3) |
--------------------------
| com |
--------------------------
實(shí)例:
#查詢某個(gè)字段后兩位字符
select right(last3, 2) as last2 from historydata limit 10
#從應(yīng)該字段取后兩位字符更新到另外一個(gè)字段
update `historydata` set `last2`=right(last3, 2)