+ Start a Discussion

SOQL with two IN in where clause with list as input

Hello All,

My query is ::
select id , name from account where name IN : NameList AND email IN : EmailList

Scenario ::
I am inserting data via dataloader with below details.
Name 1   xxx@yyy.com
Name 2   sss@rrr.com
Name 3   fff@uuu.com

I am trying to check in system on account object before insert whether any account record exists with the name and email combination.
Let me know whether two IN parameters as list in where clause will look for the data in the combination i gave ?
Ex :: Name 1 with only xxx@yyy.com and not with sss@rrr.com & fff@uuu.com

Shailendra Singh ParmarShailendra Singh Parmar
Hi ,
It will not check combination instead it will give you result where Name match with any of provided list and email match with any of provided list. You need to then loop throw matched records and do comparision again in apex. You still need to query records so you got matching records but for one and one matching you need to have apex code.

Vasani ParthVasani Parth
This will perfectly work . Here's a small example 
SELECT Id,Name,Rating FROM Account where name IN ('Edge Communications','GenePoint') AND Rating in ('Hot','Warm','Cold')
Please mark this as the best answer if this helps