-2

I have a column:

| Duration  |
| --------  |
| 32 minutes|
| 27minutes |
| 20 mins   |
| 15        |

I want to remove the text so that only the numbers remain, but as the text is varied I'm at a loss how to do so. I've reviewed multiple solutions and none seem to accomplish the job in an elegant way.

I had another column that was distance, and every row contained 'km' at the end so I was able to use replace.

UPDATE runner_orders
SET distance = REPLACE(distance,'km','')

I tried doing the same but using a wildcard, this didn't work.

UPDATE runner_orders
SET duration = REPLACE(duration, 'min%','')

Any input is well appreciated.

1 Answers1

-1

You can achieve this with CAST

UPDATE runner_orders SET duration = CAST(duration as INT); 
mustafa
  • 36
  • 5