I cannot find the way how i can delete one of the stored ids in varchar column.
id fieldid
1 ,5,13,15,66,443,
how i can delete, lets say 15 from this field id?
The correct logic is:
UPDATE <your_table_name>
SET fieldid = REPLACE(fieldid, ',15,', ',')
---------------------------------------^----^ these commas a really important
WHERE id = 1;
However, storing list of numbers of strings is bad, bad, bad in SQL:
Sometimes, you are stuck with someone else's really, really, really bad design decisions.
You gave give REPLACE
a shot though
DECLARE @Test VARCHAR(50)
SET @Test = ',5,13,15,66,443,'
SELECT REPLACE(@Test,'15,','')
,5,13,66,443,
Check with ORACLE
UPDATE <your_table_name>
SET fieldid = REPLACE(fieldid,',15','')
WHERE id = 1;
This will replace ',15' with empty string. Like remove from string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.