I have a table with two string columns: Url and ModelId. I need to return records for which Url contains ModelId, something like this:
SELECT Id, Url, ModelId WHERE Url like "%ModelId%"
I have a table with two string columns: Url and ModelId. I need to return records for which Url contains ModelId, something like this:
SELECT Id, Url, ModelId WHERE Url like "%ModelId%"
SELECT Id, Url, ModelId
WHERE Url LIKE CONCAT('%', ModelId, '%')
You can not just concat the strings, you must also escape the field from % and _:
SELECT Id, Url, ModelId
WHERE Url LIKE CONCAT('%', REPLACE(REPLACE(ModelId,'%','\%'),'_','\_'), '%'), '%')
Here is the query:
SELECT Id, Url, ModelId WHERE Url LIKE CONCAT('%', ModelId, '%')
SELECT Id, Url, ModelId from <table> WHERE Url like '%' + ModelId + '%'