Postgres:错误:运算符不存在:字符变化 = bigint [英] Postgres: ERROR: operator does not exist: character varying = bigint

查看:140
本文介绍了Postgres:错误:运算符不存在:字符变化 = bigint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询是这样的.我尝试获取 ID 列表的状态.

My query is something like this. I try to get a status for a list of ids.

select order_number, order_status_name
from data.order_fact s
join data.order_status_dim l
on s.order_status_key = l.order_status_key
where 
order_number in (1512011196169,1512011760019,1512011898493,1512011972111)

我收到一个错误提示:

ERROR:  operator does not exist: character varying = bigint
LINE 6: order_number in (1512011196169,1512011760019,1512011898493,1...
                     ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

您对我应该如何改革 ID 以使其正常工作有任何线索吗?非常感谢!

Do you have any clue on how I should reform the ids to get it work? Thanks a lot!

推荐答案

您的 order_number 是一个 varchar,您无法将其与数字进行比较(123 是一个SQL中的数字,'123'是字符串常量)

Your order_number is a varchar, you can't compare that to a number (123 is a number in SQL, '123' is a string constant)

您需要使用字符串文字:

You need to use string literals:

order_number in ('1512011196169','1512011760019','1512011898493','1512011972111')

手册中的更多详细信息:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

More details in the manual:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS

这篇关于Postgres:错误:运算符不存在:字符变化 = bigint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆