Update table values in mysql from another table using joins
I am trying to update a collection of computer hostnames to match recently
changed room numbers. The hostnames in the database are formatted like
FL-itf2106a with 2106 being the old room number. I already have a list in
another table that has the old and new room numbers on the same row. I
have been trying to strip all the non-numerics out of the string for the
hostname and join that to the updates table unsuccessfully.
update computers c
inner join updates u on u.old = (select NumericOnly(c.hostname) where
hostname like "%FC%")
set c.hostname = concat('classf', u.new);
NumericOnly is a User function that removes all characters but numerics
from a string.
I am trying to set the hostname column equal to classf + the new room number.
No comments:
Post a Comment