MySQL uses another field for fuzzy query
P粉333186285
P粉333186285 2023-07-25 11:34:12
0
2
484
<p>I have a table with two string columns: Url and ModelId. I need to return those records whose URL contains ModelId, similar to this query: </p> <pre class="brush:php;toolbar:false;">SELECT Id, Url, ModelId WHERE Url like "%ModelId%"</pre> <p><br /></p>
P粉333186285
P粉333186285

reply all(2)
P粉418351692

You can't just concatenate strings, you must also escape the fields, using the special characters % and _:

SELECT Id, Url, ModelId 
WHERE Url LIKE CONCAT('%', REPLACE(REPLACE(ModelId,'%','\%'),'_','\_'), '%'), '%')
P粉199248808
SELECT Id, Url, ModelId 
WHERE Url LIKE CONCAT('%', ModelId, '%')
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template