postgresql - Postgres : ERROR: operator does not exist: character varying = bigint

标签 postgresql

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

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 以使其正常工作,您是否有任何线索? 非常感谢!

最佳答案

您的 order_number 是一个 varchar,您不能将它与数字进行比较(123 在 SQL 中是一个数字,'123'是一个字符串常量)

您需要使用字符串文字:

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

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

关于postgresql - Postgres : ERROR: operator does not exist: character varying = bigint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34740652/

相关文章:

sql - 如何在postgreSQL中模拟数据库崩溃

postgresql - 微调约束触发器何时触发

sql - 将两个结果合并到一个表中

Postgresql 使用时区 UTC 创建表字段名时间戳

postgresql - TypeORM:订阅两个模型

sql - "Explode"SQL函数返回的表成列

sql - 使用 SQL 查询选择月销售高峰

java - PSQLException : ERROR: relation "TABLE_NAME" does not exist

mysql - 将本地 mysql 数据库从 cakephp 应用程序迁移到 heroku postgres

php - 由于连字符导致的 pq_query 语法错误。我怎么写这个?