Sử dụng REGEXP với mẫu '[a-zA-Z]' để tìm các bản ghi chứa ít nhất một ký tự chữ. Cú pháp:
SELECT tenCot FROM tenBang WHERE tenCot REGEXP '[a-zA-Z]';
Tạo bảng demo41:
mysql> CREATE TABLE demo41 (
-> name VARCHAR(40)
-> );
Chèn dữ liệu:
mysql> INSERT INTO demo41 VALUES('John Smith34');
mysql> INSERT INTO demo41 VALUES('John Smith');
mysql> INSERT INTO demo41 VALUES('9234John Smith');
mysql> INSERT INTO demo41 VALUES('john smith');
mysql> INSERT INTO demo41 VALUES('98775');
Hiển thị dữ liệu:
mysql> SELECT * FROM demo41;
Kết quả:
+----------------+
| name |
+----------------+
| John Smith34 |
| John Smith |
| 9234John Smith |
| john smith |
| 98775 |
+----------------+
Truy vấn lọc:
mysql> SELECT name FROM demo41 WHERE name REGEXP '[a-zA-Z]';
Kết quả (loại bỏ '98775'):
+----------------+
| name |
+----------------+
| John Smith34 |
| John Smith |
| 9234John Smith |
| john smith |
+----------------+