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
Nicholas SartorNicholas Sartor 

SOQL querying url addresses

Hi all!

I'm struggling to get the right SOQL query in a way that I can search and filter by URL addresses, through the API.

We have a custom field "Crunchbase_URL__c", which can be both written by my application (usign the REST API), or filled in manually by the used.

Most of the the times, when the URL was filled automatically, the line
.../services/data/v47.0/query?q=SELECT Name FROM Account WHERE Crunchbase_URL__c = 'https://www.crunchbase.com/organization/{the permalink that I'm searching}'
will work without any issues, but sometimes when the user would only type www.crunchbase.com/.... without the https the query obvioulsly comes back empty.

I tried to use 'LIKE' instead of the '=' operator, but it looks like it would only work with a string beginning with the query term. So
SELECT Name FROM Account WHERE Crunchbase_URL__c LIKE '%crunchbase.com/....'
is not working.

Currently my workaround is to query for all the possibilities (from my Javascript code):
"Crunchbase_URL__c = 'https://www.crunchbase.com/organization/" + Sel_row.QueryName + "'" +
                            " OR Crunchbase_URL__c = 'https://crunchbase.com/organization/" + Sel_row.QueryName + "'" +
                            " OR Crunchbase_URL__c = 'http://www.crunchbase.com/organization/" + Sel_row.QueryName + "'" +
                            " OR Crunchbase_URL__c = 'http://crunchbase.com/organization/" + Sel_row.QueryName + "'" +
                            " OR Crunchbase_URL__c = 'crunchbase.com/organization/" + Sel_row.QueryName + "'" +
                            " OR Crunchbase_URL__c = 'www.crunchbase.com/organization/" + Sel_row.QueryName + "' "
but this hardly looks like the right approach.

furthermore, when querying for the standard Website field I have exactly the same issues.

Thanks for your help!
Marcos LasoMarcos Laso
You can user another '%' character when using LIKE to use as wilcard at the end of the word
 
SELECT Name FROM Account WHERE Crunchbase_URL__c LIKE '%crunchbase.com%'