sql - '! =' and ' <>' postgresql 中的运算符

标签 sql database postgresql

根据 postgresql manual !=<> 相同.实际上,情况似乎并非如此:

psql=> select 1 where 1!=-1;
ERROR:  operator does not exist: integer !=- integer
LINE 1: select 1 where 1!=-1;
                        ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
psql=> select 1 where 1<>-1;
 ?column? 
----------
        1
(1 row)

这是错误还是手册未涵盖的预期行为?

最佳答案

你需要写一个空格让 postgres 知道它是一个 != 运算符而不是 !=-:

select 1 != -1;

或者你可以把它放在括号里:

select 1!=(-1);

关于sql - '! =' and ' <>' postgresql 中的运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60446258/

相关文章:

java - 将日期插入sql数据库

mysql - 在远程服务器上部署 MySQL 数据库

mysql - 时序数据库线性存储

java - PostgreSql 失败的 Spring Boot 数据源自动配置

sql - 在SQL中将两个计数结果相互划分

sql - 删除的 SQL 条目是否仍然占用空间/行?

sql - Postgres ltree 模块,使用所有子相关路径更新节点的 id

sql - DB2 EBCDIC 值函数

python - 使用 python 从查询返回元组

python - 用于更新表的 SQLAlchemy 自定义约束