How to select integer values only from a varchar column in PostgreSQL

孤者浪人 提交于 2021-02-07 12:15:28

问题


How to select integer values only from a varchar column in PostgreSQL?

If the column contains:

abc
70
3g
71
1.5

I'd like to select only:

70
71

I'm struggling to find functions like: is_numeric, is_integer, to do something like this:

SELECT column
FROM table
WHERE isinteger(column)

Any ideas? Thank you.


回答1:


SELECT column
FROM table
WHERE column ~ '^\d+$'


来源:https://stackoverflow.com/questions/15163793/how-to-select-integer-values-only-from-a-varchar-column-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!