How to check if a string contains any string of a column in MySQL and vice versa?
13,229
Not sure if I understand you correctly, but are you maybe looking for this:
SELECT ... WHERE column LIKE "%string%" OR string LIKE CONCAT("%", column, "%")
Author by
Zananok
Updated on June 04, 2022Comments
-
Zananok almost 2 years
By vice versa, I mean, check if any of the strings in a column contains the string.
Example:
String a = "Peperoni"
MySQL column:
{ "PPeperoni_123", "roni", "hello world" }
It should return the first 2 rows.
(Note: im looking for the query string for this)
-
Zananok about 11 yearsThank you, that is exactly what I am looking for.
-
Zananok about 11 yearsThank you, that also helps me on a similar issue.
-
aidonsnous over 8 yearsLIKE CONCAT("%", column, "%") is not secure if the value of the column contains %
-
aidonsnous over 8 yearsSounds like can not return that result it compares string phonetically