查询或语句

问题描述 投票:0回答:1

有人可以帮我解答疑问吗?我不知道如何添加这个 OR 语句

select id, status, from custom_Object__c where id in ('id1' or 'id2') 

我也尝试过

select id, status, from custom_Object__c where (id = 'id1' or 'id2')

谁能告诉我如何在 IN 语句中对 2 个 id 使用 OR 语句?谢谢!

我也尝试过

select id, status, from custom_Object__c where (id = 'id1' or 'id2')

谁能告诉我如何在 IN 语句中对 2 个 id 使用 OR 语句?

sql salesforce soql
1个回答
0
投票

要在 where 子句中使用 OR 条件,您可以执行以下操作:

select id, status 
from custom_Object__c 
where id = id1' OR id ='id2'

SQL 中的

IN
构造可以用作“快捷方式”,例如上述查询的等价如下:

select id, status 
from custom_Object__c 
where id in ('id1','id2') 

在这里,您只需列出 id 可能等于的所需值,并用逗号分隔(并且您不需要在该列表中指定“或”)。

© www.soinside.com 2019 - 2024. All rights reserved.