1
   list<Contact> conlist = [select id, Email, Communication_Agreement__c 
                            from Contact 
                            where name='ajay'];
2
  • It's not really clear ! What do you mean by two names ?
    – SF_user
    Commented Feb 4, 2015 at 9:57
  • where name='ajay','vijay' like that.how to see another record id,email,Communication_Agreement__c.
    – user
    Commented Feb 4, 2015 at 9:58

3 Answers 3

6

Try to use the AND or OR in your query:

   list<Contact> conlist = [select id, Email, Communication_Agreement__c 
                            from Contact 
                            where name = 'ajay'
                            OR name = 'blaah'];

Additionaly you can create a list with multiple values and use IN:

List<String> mylist = new List<String>();
l.add('param1');
l.add('param2');

list<Contact> conlist = [select id, Email, Communication_Agreement__c 
                         from Contact 
                         where name IN :mylist];
1

Try something like this.

Set<String> nameval=new Set<String>();
nameval.add('Test');
nameval.add('Test_1');
List<Contact> conlist = [Select Id,Email,Communication_Agreement__c from Contact where name in: nameval];
0
0

Try this :

list<Contact> conlist = [select id, Name, Email,Communication_Agreement__c 
                            from Contact 
                            where Name='ajay'
                            or Name='vijay'];
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .