-1

I have a database table conataining some columns. I won't go into details but the point is that a column represents the description. This description contains a variety of information that I want to separate and add in different new columns. Example:

Row before quering

id: 1
description: '12KG, 16mm

Row after quering

id: 1
description: '12KG, 16mm
weight: 12KG
length: 16mm

I found a way to do this via python but I would like to know if there's a way of doing it with MySql only.

Thanos
  • 358
  • 1
  • 3
  • 6
  • Should redesign schema, https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad. – user3783243 Jun 02 '22 at 12:46
  • Firstly divide the value to separate tokens by comma delimiter. Then categorize them by the measurement unit postfix and assign into proper column. PS. Why `'10m^2'` is ignored? – Akina Jun 02 '22 at 12:50
  • @user3783243 That's what I'm trying to do. They gave me this schema with more than 30k rows to fix this exact issue. – Thanos Jun 02 '22 at 12:57
  • @Akina Thanks for the answer. In the end, I've found it unescessary to add the `10m^2` but forgot to delete it in 'Row after quering' before posting. – Thanos Jun 02 '22 at 12:59

0 Answers0