所以,我有这个问题:
SELECT count(*) AS count FROM table1 INNER JOIN "some query"
WHERE "some more query"
OR (table.smowid NOT LIKE (58)) OR "rest of query"
很抱歉代码不清楚,完整查询非常大,但问题出在table.smowid NOT LIKE (58)
部分。
这是我得到的错误:
ERROR: operator does not exist: integer !~~ integer
LINE 11: or ( (table.smowid) NOT LIKE (58))
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
我很遗憾,对模型和类型不太了解,但为什么数据库在从整数变为整数时会抱怨?
我通过说(CAST (table.smowid) AS INTEGER) NOT LIKE (58)
尝试了CASTING,但这不起作用,我也试过了(table.smowid :: integer) NOT LIKE (58)
但是由于某些原因也没有用。
那么,我该怎么办?感谢您的帮助。
答案 0 :(得分:2)
NOT LIKE
及其等效的!~~
绝对不是整数运算符。你想用整数pattern matching operators做什么?
有一种方法可以使用它,但首先必须将整数(或format)转换为文本。
答案 1 :(得分:2)
您应该将它们都投射到文本中,或者更好的是,将smowis
列与所有smowi
值一起作为文本,以节省每次投射的开销。