mysql 判断字符串是否是数字

查询表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);

如有错误,欢迎拍砖

你可能感兴趣的:(mysql)