SELECT only rows that contain only alphanumeric characters in MySQL

前端 未结 6 1183
天涯浪人
天涯浪人 2020-12-05 01:42

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]\';
         


        
6条回答
  •  盖世英雄少女心
    2020-12-05 02:24

    There is also this:

    select m from table where not regexp_like(m, '^[0-9]\d+$')
    

    which selects the rows that contains characters from the column you want (which is m in the example but you can change).

    Most of the combinations don't work properly in Oracle platforms but this does. Sharing for future reference.

提交回复
热议问题