gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 14:29:50 25 4
gpt4 key购买 nike

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

    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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com