function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GobbledigookGobbledigook 

Noob SOQL question.

I've been searching around the internetz, but I haven't found a definitive answer. 

 

I'm trying to write a search method that filters based on Record Type. (I'm only searching one object, hence no SOSL)

 

It returns anything that contains the search string itself, so I'm using like so far.  I want to know a few things:

 

Does SOQL have support for Contains, (or anything to that effect)? 

 

Does Like check strings themselves?  For example, if I type 'Hello World' in the search string, will it return things only with the phrase 'Hello World' or will it return results on 'Hello' and 'World' seperately? 

alexbalexb

You can character that one could liken to regular expressions. '_' and '%'

 

I believe '_' means one of any character and '%' means one or more of any character.

 

I can't find the documentation in the online reference, but I've seen it there, under the SOQL < WHERE clause section, but, here is some examples of it:

http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_calls_soql.htm

 

I think it follows SQL in this manner:

http://www.w3schools.com/sql/sql_like.asp

http://www.sql-tutorial.net/SQL-LIKE.asp

bob_buzzardbob_buzzard

I believe that % means 0 or more of any character, so if you have some soql like:

 

select Name from Account where name LIKE '%YMCA%'

 

this will find any account where YMCA appears anywhere in the name - middle, start, end.