知乎專欄 | 多維度架構 |
判斷非數字字元
select '看89700' regexp '^[0-9]+$' select '89看700' regexp '^[0-9]+$' select '89700看' regexp '^[0-9]+$'
應用到實際工作中
select count(*) from accounts a where a.name != '' and not a.name regexp '^[0-9]+$'; select count(*) from accounts a,members m where a.member = m.id and a.name != '' and not a.name regexp '^[0-9]+$' group by member; SELECT * FROM tablename WHERE SUBSTRING(fieldname, 1, 1) REGEXP '[[:digit:]]';