有没有办法只选择mysql中字段的整数? [英] Is there a way to select only integers of a field in mysql?

查看:42
本文介绍了有没有办法只选择mysql中字段的整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想搜索数字,但其中一些有 - 字符或它们之间的空格,有没有办法像

I want to search for numbers, but some of them have - characters or spaces inbetween them, is there a way to do like a

从表中仅选择号码(电话)

select numbersonly(phone) from table

?

谢谢.

推荐答案

在您的 WHERE 子句中包含此内容:

Include this in your WHERE clause:

WHERE CONVERT(your_column, SIGNED INTEGER) IS NOT NULL 

并使用 REPLACE 函数对其进行扩充.

and augment it with the REPLACE function.

因此,根据您的 SELECT 语句,更新后的内容可能类似于:

So based on your SELECT statement the updated could look something like:

SELECT phone FROM table
WHERE CONVERT(REPLACE(REPLACE(phone, '-', ''), ' ', ''), BIGINT) IS NOT NULL 

这篇关于有没有办法只选择mysql中字段的整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆