我正在使用Postgresql并尝试在两个字段上连接两个表:
SELECT a.high, a.low, a.stname, a.zipcode, b.bhs, b.street_numb, b.street, b.address, b.zipcode
FROM bin a
JOIN zp b
ON (a.stname = b.street) and (a.low = b.street_numb);
但是,我收到以下错误:
ERROR: operator does not exist: character varying = integer
LINE 4: on (a.stname = b.street) and (a.low = b.street_numb);
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
我如何才能获得正确的结果?
答案 0 :(得分:0)
您要求Postgres比较两种不同类型,character
和integer
。如果您确定a.low
是数字,
CAST (a.low AS INT) = b.street_numb
答案 1 :(得分:0)
ALTER TABLE zp ALTER COLUMN street_numb TYPE character(5);