Idsa Idsa - 2 months ago 18
MySQL Question

MySQL like another field

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%"

Answer
SELECT Id, Url, ModelId 
WHERE Url LIKE CONCAT('%', ModelId, '%')
Comments