如何将整数转换为字符串作为PostgreSQL查询的一部分?
例如,我需要:
SELECT * FROM table WHERE <some integer> = 'string of numbers'
其中<some integer>
可以是1到15位数的任意长度.
如何将整数转换为字符串作为PostgreSQL查询的一部分?
例如,我需要:
SELECT * FROM table WHERE <some integer> = 'string of numbers'
其中<some integer>
可以是1到15位数的任意长度.
因为数字最多可以是15位,所以需要转换为64位(8字节)整数.试试这个:
SELECT * FROM table
WHERE myint = mytext::int8
::
名演员的运营商历史悠久,但很方便.Postgres也符合SQL标准语法
myint = cast ( mytext as int8)
如果要将文本与int
进行比较,请将int
转换为文本:
SELECT * FROM table
WHERE myint::varchar(255) = mytext