要求:将operate_type的属性值更新,
如果operate_type的属性值是以'1,'开头的字符串,则将'1,'删除保留'1,'后面的字符串.
(原字符串为:'1,23,12',更新后为:'23,12').
2 个解决方案
#1
update ga_company a SET a.operate_type=(
SELECT c.op FROM
(select SUBSTRING(b.operate_type,3) op,b.company_id id
from ga_company b
where b.operate_type LIKE '1,%') as c
where c.id = a.company_id)
SELECT c.op FROM
(select SUBSTRING(b.operate_type,3) op,b.company_id id
from ga_company b
where b.operate_type LIKE '1,%') as c
where c.id = a.company_id)
#2
直接截取就可以了。
update t
set c = substr(c,2,100)
where c like '1,%'
update t
set c = substr(c,2,100)
where c like '1,%'
#1
update ga_company a SET a.operate_type=(
SELECT c.op FROM
(select SUBSTRING(b.operate_type,3) op,b.company_id id
from ga_company b
where b.operate_type LIKE '1,%') as c
where c.id = a.company_id)
SELECT c.op FROM
(select SUBSTRING(b.operate_type,3) op,b.company_id id
from ga_company b
where b.operate_type LIKE '1,%') as c
where c.id = a.company_id)
#2
直接截取就可以了。
update t
set c = substr(c,2,100)
where c like '1,%'
update t
set c = substr(c,2,100)
where c like '1,%'