Mark Henry
Mark Henry

Reputation: 2709

copy part of a string in column to another in MYSQL

I want to copy the part of the content of column 'alttext' to 'direction' for those records where alttext contains the word 'blick'

UPDATE sv_gps SET direction = alttext WHERE alttext LIKE '%blick%'

so far, so good but I only want to copy the part of the string that begins with the word blick (and continues to the end). That is wehere I love your help.

e.g.

alttext:
Bergrestaurant und hotel Schonbuhel. Blick ins Glemmtal.

schould result in

direction:
Blick ins Glemmtal.

Upvotes: 1

Views: 511

Answers (1)

juergen d
juergen d

Reputation: 204854

UPDATE sv_gps 
SET direction = substring(alttext, instr(alttext, 'blick'))
WHERE alttext LIKE '%blick%'

Upvotes: 1

Related Questions