Search code examples
mysqlsql-like

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

Solution

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