当前位置: 动力学知识库 > 问答 > 编程问答 >

Customising MySql table values

问题描述:

I have a table in MySql, the table has 3 fields (name, date, number). The table connected to my app via PHP.

What I need is to make MySql to accept only English numbers. I don't want to do it via PHP, is there any way to do it in MySql to restrict it from accepting such as (Arabic, Parisian).

If there's any options can I do it from MySql.

Thanks

网友答案:

You can verify that easily with a regex,

SELECT * FROM yourTable WHERE number REGEXP '^[0-9]*$';

Edit : If your goal is only to block Arabic text, then here a regex that would select only ASCII character from the space to the tild(0-127).

SELECT * FROM yourTable where number REGEXP '^[ -~]*$'
分享给朋友:
您可能感兴趣的文章:
随机阅读: