根据索引从逗号分隔的字符串中删除值

时间:2019-05-15 09:05:47

标签: mysql

all_bet_no
1,2,3,4,5
1,2,4,5
1,2,4,5
1,2,4,5

all_bet_amount

100,200,300,400,500

100,200,400,500

100,600,800,900

100,100,100,100

假设我要替换2。

将表更新为mp1设置mp1.all_bet_no = TRIM(BOTH','FROM REPLACE(CONCAT(',',mp1.all_bet_no,','),CONCAT(',',@ edit_betno,','), ',')),mp1.all_bet_amount = TRIM(BOTH','FROM REPLACE(CONCAT(',',mp1.all_bet_amount,','),CONCAT(',',SUBSTRING_INDEX(SUBSTRING_INDEX(mp1.all_bet_amount,', ',FIND_IN_SET(@ edit_betno,mp1.all_bet_no)),',',-1),','),','))

输出必须为

all_bet_no
1,3,4,5
1,4,5
1,4,5
1,4,5

all_bet_amount

100,300,400,500

100,400,500

100,800,900

100,100,100

0 个答案:

没有答案