2

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 result 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.

1 Answer 1

2

What about something like this, using the REGEX operator :

UPDATE  location
SET     area = concat('Area ', area)
WHERE   area REGEXP '^[0-9]{1,2}$'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.