sql - postGreSQL 在数据类型匹配时请求类型转换?

标签 sql postgresql

所以我一直在这里尝试这个查询:

    SELECT
     account.customer_client_code,
     account.client_account_number,
     account.first_name,
     account.last_name,
     debt_trans.trans_date,
     debt_trans.debt_id,
     debt_trans.debt_trans_id,
     debt_trans.receiver,
     debt_trans.type_name,
     debt_trans.client_id,
     debt_trans.amount

    FROM
     debt_trans 

    INNER JOIN
     account 

    ON
     account.client_id= debt_trans.client_id

      /* Both fields here are of int8 datatype */

    WHERE
     debt_trans.customer_id = 'CMC' 
     and
     account.customer_client_code like ('UBC2903','UBCO') 
     and 
     debt_trans.type_name='Credit Card'
     and
     debt_trans.operator = 'RECEIVED'

 /*All of these fields here are of varchar datatype */

但我已经检查并仔细检查了所有数据类型,不应该有任何类型转换。我收到的错误消息如下:

“错误:运算符不存在:字符变化 ~~ 记录提示:没有运算符匹配给定的名称和参数类型。您可能需要添加显式类型转换。位置:492”

有什么问题的提示吗?

最佳答案

错误消息与此行有关:

account.customer_client_code like ('UBC2903','UBCO')

如果您尝试查看 account.customer_client_code 是否是 'UBC2903''UBCO' 之一,那么您应该使用IN 运算符:

account.customer_client_code IN ('UBC2903','UBCO')

关于sql - postGreSQL 在数据类型匹配时请求类型转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53461056/

相关文章:

postgresql - Postgres 的 Jasper 服务器社区版安装问题

sql - 在 Access VBA 中附加到表时出错

反斜杠和数组名称的PHP json_encode问题

mysql - 优化primary id关系表

sql - 如何计算选择查询中每个组的百分比

postgresql - 高效创建日期

javascript - 在多个字段之间使用 ILIKE 子句进行序列化查询

java - 在 Postgres 和 Java 中将字符串转换为 UUID

mysql - 在查询的第一行得到错误的结果

PHP - 在 HTML 表中输出 2 个查询的结果