当前位置:Gxlcms > mysql > MySQL判断字符串是否是数字

MySQL判断字符串是否是数字

时间:2021-07-01 10:21:17 帮助过:41人阅读

查询表table_name中col_name(字符串类型)的值是数字的记录 SELECT col_name,CAST(col_name AS UNSIGNED INTEGER) AS val FROM table_name WHERE col_name=0 OR col_name0 HAVING CHAR_LENGTH(col_name)=CHAR_LENGTH(val);

查询表table_name中col_name(字符串类型)的值是数字的记录

SELECT col_name,CAST(col_name AS UNSIGNED INTEGER) AS val
FROM table_name
WHERE col_name="0" OR col_name>0
HAVING CHAR_LENGTH(col_name)=CHAR_LENGTH(val);

人气教程排行