NOT LIKE operator in SOQL
Not Like keyword used for like SOQL means if we found/search the records where Email is not end with ‘G’ character then we use NOT LIKE operator. As given below of NOT LIKE operator use.
We are getting Email fields from Contact object where Email end with x and using 1 to z except ‘x’ in like soql for example Email=’user@test.com’
SOQL using LIKE:
Select id, email from contact where email like '%a' or email like '%b' or email like '%c' or email like '%d' or email like '%e' or email like '%f' or email like '%g' email like '%h' or email like '%i' or email like '%j' or email like '%k' or email like '%l' or email like '%m' or email like '%n' or email like '%o' or email like '%p' or email like '%q' or email like '%r' or email like '%s' or email like '%t' or email like '%u' or email like '%v' or email like '%w' or email like '%y' or email like '%z';
As we can see it’s really hectic using such long SOQL so to overcome this thing now we can use NOT LIKE in SOQL.
SOQL using NOT LIKE:
Select id, email from contact where NOT email like '%x';
No comments:
Post a Comment