You need to sign in to do that
Don't have an account?
javierjies
Issues with a SOQL query
Hello everyone!!!
I have done an APEX class. If I use this query;
Contact C=[select Name from Contact where Id not in ('a0U80000001p4TEEAY,a0U80000001p4T9EAI')];
It works! It gives me the Contacts I want!
But if I do this;
string help='a0U80000001p4TEEAY,a0U80000001p4T9EAI';
Contact C=[select Name from Contact where Id not in (:help)];
It doesn't work!
How do I pass parameters correctly?!?!?
Thanks in advance!!
You should be using an array or list since you want to make sure it's not one of the two values.
list<Contact> C=[select Name from Contact where Id not in ('a0U80000001p4TEEAY,a0U80000001p4T9EAI')];
thank you!
but the problem persists...
Try the following code.
List<String> idsIWantToAvoid = new List<String>(); idsIWantToAvoid.add('a0U80000001p4TEEAY'); idsIWantToAvoid.add('a0U80000001p4T9EAI'); list<Contact> C=[select Name from Contact where Id not in :idsIWantToAvoid ];
Thanks AlsoDoug, but I can't save the class because it gives me an error message!
Save Error: Invalid bind expression type of LIST: String for column of type String