how to delete single record from list

时间:2018-12-19 11:19:13

标签: mysql sql

I have a record in table column like this (1001,1002,1003,1004,1005) and I want to delete "1003" from this list. Please help me.

2 个答案:

答案 0 :(得分:0)

For your own good, don't store data like this. This type of issue is not, by far, the biggest problem you will run into.

This being said, you can solve you issue by using:

UPDATE TABLE
SET COLUMN = REPLACE (COLUMN, ',1003,', ',')
WHERE ID = PK;

答案 1 :(得分:0)

even this will work:

   update tablename set column=(select 
   substr(column,1,instr(colname,',',2))||susbtr(column,instr(column,',',3),length(column)- 
   instr(column,',',3)) from tablename where id=value;