我的查询是这样的。我试图获得一个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.
你是否有任何关于我应该如何改革ids以使其发挥作用的线索? 非常感谢!
答案 0 :(得分:9)
您的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
答案 1 :(得分:0)
如果您无法更改in
中的数字类型,则可以使用cast
:
select * from numbers_as_string
where cast(my_numbers_as_string as int) in (1,2,3)