-2

Edit :

I give another example,

products_table

| ID | product_name | images |
|---------------------------------------|
| 1 | Phone | img1.jpg,img2.jpg
| 2 | Canon | img1.jpg,img2.jpg,img3.jpg
| 3 | Cocac | img1.jpg,img2.jpg,img3.jpg,img4.jpg
| 4 | Lamps | img1.jpg,img2.jpg,img3.jpg,img4.jpg

Lats say I remove image "img3.jpg" from Lamps product without remove other images. What is the SQL call to this?

MSufian
  • 31
  • 1
  • 7
  • 2
    Possible duplicate of [The best way to remove value from SET field?](https://stackoverflow.com/questions/14642658/the-best-way-to-remove-value-from-set-field) –  May 25 '17 at 06:46
  • 1
    Simple. DON'T have a comma separated list in an RDBMS. – Strawberry May 25 '17 at 07:04

1 Answers1

2
$this->db->query("UPDATE products_table SET images=replace(images, 'img3.jpg,',''),images=replace(images, ',img3.jpg','') WHERE product_name='Lamps'");
Md. Nashir Uddin
  • 730
  • 7
  • 20