I have a table called location
with a field area
. This field can contain various types of values.
Example: London
, New York
, Tokoyo
, 3
, 10
, 99
, 149
, 2743
, etc.
Using a regular expression I want to update this field if it containes a 1 or 2 digit number by adding the word Area
. So using the example above, the update will resul开发者_运维问答t in Area 3
, Area 10
, Area 99
.
The rest of the values will be ignored as they don't meet the criteria. Hopefully that makes sence.
What about something like this, using the REGEX
operator :
UPDATE location
SET area = concat('Area ', area)
WHERE area REGEXP '^[0-9]{1,2}$'
精彩评论