仅选择MySQL中仅包含字母数字字符的行 [英] SELECT only rows that contain only alphanumeric characters in MySQL

查看:593
本文介绍了仅选择MySQL中仅包含字母数字字符的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方法选择MySQL中仅包含字母数字字符的所有行:

I'm trying to select all rows that contain only alphanumeric characters in MySQL using:

SELECT * FROM table WHERE column REGEXP '[A-Za-z0-9]';

但是,无论它们包含非字母数字字符,它都会返回所有行.

However, it's returning all rows, regardless of the fact that they contain non-alphanumeric characters.

推荐答案

尝试以下代码:

SELECT * FROM table WHERE column REGEXP '^[A-Za-z0-9]+$'

这确保所有字符都匹配.

This makes sure that all characters match.

这篇关于仅选择MySQL中仅包含字母数字字符的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆