Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql query to select a column with only alphabetical characters

Tags:

sql

mysql

I need to display records from mysql database where a particular column has only alphabets.

eg,

Table Name: data

 column
 abcde
 12345
 xyz
 123

so the output should be abcde and xyz only. So far i tried using pattern match but no luck

here is what is use yet SELECT * FROM listing WHERE Zip LIKE '[^a-zA-Z]'

like image 817
Ranjit Singh Avatar asked Dec 09 '22 09:12

Ranjit Singh


2 Answers

Try this code

SELECT * FROM listing WHERE Zip REGEXP  '^[A-z]+$'
like image 105
Ekramul Hoque Avatar answered Dec 11 '22 08:12

Ekramul Hoque


Try regexp:

SELECT * FROM listing WHERE Zip REGEXP '^[a-zA-Z.]+$'
like image 23
smozgur Avatar answered Dec 11 '22 10:12

smozgur