728x90
SOQL 에서 where 절에 like를 사용할 때 여러 값을 동시에 할 때는 Set<String> 형태로 변수를 만들어 넘겨줍니다.
Set<String> accountNameMatches = new Set<String> { 'A%', 'United%', '%&%' };
List<Account> accList = [
SELECT
Id
, Name
FROM
Account
WHERE
Name LIKE :accountNameMatches
order by
Name
];
for(Account a : accList) {
System.debug(a.Id + ' / ' + a.Name);
}
Debug 결과
0016F00003kmTsaQAE / Acme
0016F00002SK3CaQAL / Grand Hotels & Resorts Ltd
0016F00002SK3CbQAL / United Oil & Gas Corp.
0016F00002SK3CfQAL / United Oil & Gas, Singapore
0016F00002SK3CeQAL / United Oil & Gas, UK
예제 데이터
728x90
'Salesforce > Development' 카테고리의 다른 글
Salesforce OAuth 2.0 - password Type (0) | 2022.06.21 |
---|---|
현재 사용자 ID 정보 가져 오기(Aura, lwc, apex, vf) (0) | 2022.04.21 |
Apex에서 종속 선택 목록 값 가져오기 (Get Dependent Picklist Values in Apex) (0) | 2022.04.20 |
Safe Navigation Operator 안전 탐색 연산자(?.) (0) | 2022.04.19 |
String.isEmpty() & String.isBlank() & String.isNotEmpty() & String.isNotBlank() 차이점 (0) | 2022.04.18 |