如何使用updatequery从逗号分隔的字符串中删除值?

68bkxrlz  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(316)
Recruiter list,Employer List,Latest Jobs,Intrested Recruiter,Recruiter Resume,Shortlisted Hr Resume

UPDATE assign SET menu=REPLACE(REPLACE(CONCAT(',', menu, ','), 'Shortlisted Hr Resume', ''), ',,', ',') WHERE hr_id='hr2911025540'

在这种情况下,我有一个字符串 Recruiter List, Shortlisted Hr Resume, Add Hr . 现在我只想删除 Shortlisted Hr Resume 但是这个查询替换了结束和输出的值 ,Employer List,Latest Jobs,Intrested Recruiter,Recruiter Resume, 那么,我该怎么做请帮帮我?
谢谢您

yr9zkbsy

yr9zkbsy1#

UPDATE groups
SET
  description =
    TRIM(BOTH ',' FROM REPLACE(CONCAT(',', description, ','), ', Shortlisted Hr Resume,', ','))
  WHERE id='1'

你也可以

UPDATE yourtable
SET
  description =
    TRIM(BOTH ',' FROM
      REPLACE(
        REPLACE(CONCAT(',',REPLACE(col, ',', ',,'), ','),',2,', ''), ',,', ',')
    )
WHERE
  FIND_IN_SET('2', description)

相关问题