I have a MySQL table with some addresses on it. I would like to find the addresses that contain double letters between the 5th and 11th position. There is a test table with some data for reference.
CREATE TABLE test(
address VARCHAR(500));
INSERT INTO test (address)
VALUES ('Western Marrow'),
('Kennffort Plains'),
('Oaksbrook Terrace'),
('Southern Old Saybrook')
The last record 'Southern Old Saybrook' should not appear because its double letter is not within the 5th and 11th position. Now, I have used this query to get the double letters:
SELECT address
from test
WHERE address REGEXP 'a{2}|b{2}|c{2}|d{2}|e{2}|f{2}|g{2}|h{2}|i{2}|j{2}|k{2}|l{2}|m{2}|n{2}|o{2}|p{2}|q{2}|r{2}|s{2}|t{2}|u{2}|v{2}|w{2}|x{2}|y{2}|z{2}';
But I am failing to conduct the search within the given range. How could I modify the query to apply the regular expression within the range?