MySQL判断字符串是否是数字
程序员文章站
2022-04-20 16:23:24
...
查询表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);