1、postgres类型转换函数cast

发布时间 2023-09-07 14:32:44作者: 站着说话不腰疼

postgres类型转换函数cast

postgres在sql执行过程中是不会自动转换类型的,比如一个字符类型=一个数值类型的条件时,会报类型转换报错。

此时需要使用cast将两个类型转成一致的。

select 1 from pg_tab where cast(str as text) = cast(num as text);