ERROR: operator does not exist: character varying = integer
时间: 2024-02-02 16:03:52 浏览: 169
json error: Use of overloaded operator [] is ambiguous错误的解决方法
This error message usually occurs when you are trying to compare a string (character varying) to an integer. PostgreSQL does not allow direct comparison between different data types.
To fix this error, you need to make sure that you are comparing the same data types. You can either convert the integer to a string using the CAST or TO_CHAR function, or convert the string to an integer using the CAST or :: operator.
For example, if you have a table with a column named "age" which is of type integer, and you want to compare it with a string "30", you can use the following query:
SELECT * FROM mytable WHERE age = CAST('30' AS INTEGER);
or
SELECT * FROM mytable WHERE age = '30'::INTEGER;
Both of these queries will convert the string "30" to an integer and then compare it with the "age" column.
阅读全文