postgres类型转换函数cast
postgres在sql执行过程中是不会自动转换类型的,比如一个字符类型=一个数值类型的条件时,会报类型转换报错。
此时需要使用cast
将两个类型转成一致的。
select 1 from pg_tab where cast(str as text) = cast(num as text);
postgres在sql执行过程中是不会自动转换类型的,比如一个字符类型=一个数值类型的条件时,会报类型转换报错。
此时需要使用cast
将两个类型转成一致的。
select 1 from pg_tab where cast(str as text) = cast(num as text);