在 postgres 中,您可以对多个项目进行比较,如下所示:

 SELECT 'test' IN ('not','in','here');

这与执行相同:
  SELECT ('test' = 'not' OR 'test' = 'in' OR 'test' = 'here');

SQL Server 是否有等效的功能?

最佳答案

它受支持,但您需要将表达式放在接受 bool 表达式的地方。例如,在 case 语句中:

select  case  when 'test' in ('not','in','here')  then 1  else 0  end

-----------
0

(1 row(s) affected)

where 子句:
select * from T where C in (1,3,5,7,9)

关于sql-server - SQL Server 功能等同于 PostgreSQL "in",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/341232/

10-11 04:20
查看更多