0

I am new to SQL query. Recently, I am appointed to add value to a database table column. The table column type is varchar(300) with value e.g. [0.2649, 0.2548, 0.4801] and I would like to add 0.01 to every single item inside the list which is

From:

0.2649, 0.2548, 0.4801

To:

0.2749, 0.2648, 0.4901

That column is with each cell contains a comma delimited list inside square brackets.

Could I know how to use sql query to do so?

F. Hauri - Give Up GitHub
  • 64,122
  • 17
  • 116
  • 137
ony4869
  • 1
  • 1
  • Are you saying that you have a column where each cell contains a comma delimited list inside square brackets.... Or the column is a JSON datatype? – RiggsFolly Jan 21 '22 at 12:53
  • Oh dear.. search for mysql split string as a starter ..and what mysq version are you on? – P.Salmon Jan 21 '22 at 12:53
  • 3
    Probably to late but worth a read so you dont make this mistake again https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad – RiggsFolly Jan 21 '22 at 12:57
  • @RiggsFolly Right – ony4869 Jan 21 '22 at 13:12
  • Parse to separate values. Add needed value. Reconstruct back. Use JSON_TABLE and JSON_ARRAYAGG. – Akina Jan 21 '22 at 14:21

0 Answers0