Idsa Idsa - 4 months ago 62
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, '%')