Panos Kalatzantonakis
Panos Kalatzantonakis

Reputation: 12683

MySQL replace part of string

I have a varchar field with latitude values.
I would like to replace part of the string, the "integer" part,

for example:

7.215555
2.584555
23.154525
12.54836
44.124556

should change to:

20.215555
20.584555
20.154525
20.54836
20.124556

Thanks in advance for your help.

Upvotes: 2

Views: 110

Answers (1)

M Khalid Junaid
M Khalid Junaid

Reputation: 64496

If 20 is a hardcoded string you want to replace with values before point you can do so

UPDATE table 
SET latitude = CONCAT('20.',SUBSTRING_INDEX(latitude ,'.',-1))

Fiddle Demo

Upvotes: 4

Related Questions