ppolyzos
ppolyzos

Reputation: 7091

How to get all rows that contain characters others than [a-zA-Z] in MySQL

I would like to ask if there is a possible way to select all rows from a table where the content of a column (varchar(255)) may contain characters others than standard english (a-zA-Z) or characters from different languages like Greek, French.

For example if the table contains the following data:

-- ID, Address --
|  1, "Test1"   | 
|  2, "Tåst2"   |
|  3, "Test1"   |

I would like to get only the 2nd row (2, "Tåst2")

I tried to use regular expression doing the following:

SELECT * FROM contact_info WHERE address NOT REGEXP '[a-zA-Z]';

But no luck!

Any help would be appreciated!

Upvotes: 1

Views: 1932

Answers (1)

Naktibalda
Naktibalda

Reputation: 14110

Match the whole text

SELECT * 
FROM contact_info 
WHERE address NOT REGEXP '^[a-zA-Z0-9]*$';

Upvotes: 3

Related Questions