0

In my table contain a column marks that value ''Mark 1,Mark 2'.I want to update this column as 1,2.

Query

   UPDATE dummy  
     SET `mark` =  CASE  
                    WHEN mark= 'Mark 1' THEN '1' 
                    WHEN  mark LIKE '%,Mark 1,Mark 2,%'  THEN '1,2,3' 
                    ELSE mark 
                    END 
robins
  • 1,668
  • 6
  • 33
  • 69
  • storing delimited values is not a correct way of storing data in RDBMS. See Normalization. – Gurwinder Singh Mar 14 '17 at 06:14
  • this is not the way you should be using a RDBMS. There are thousands of questions here from people who took this path and are now stuggling Don't save CSV in a column http://stackoverflow.com/questions/41304945/best-type-of-indexing-when-there-is-like-clause/41305027#41305027 http://stackoverflow.com/questions/41215624/sql-table-with-list-entry-vs-sql-table-with-a-row-for-each-entry/41215681#41215681 – e4c5 Mar 14 '17 at 06:18
  • 1
    You have not asked a question. – Bill Karwin Mar 14 '17 at 06:19

1 Answers1

3

Try this

 UPDATE dummy  
     SET `mark` =  Replace(`mark`,'mark ','')