I cannot figure out how to query a table on a column being contained in a string.
Table companies:
id | title
----------
1 | abc
2 | abcd
3 | bcde
4 | xyfa
I have tried:
SELECT * FROM companies WHERE CONTAINS("ABCDEFG Ltd", title)
SELECT * FROM companies WHERE CONCAT("%", title, "%") LIKE "ABCDEFG Ltd"
I would like to return:
id | title
----------
1 | abc
2 | abcd
3 | bcde
CONTAINS()version is going to throw an error (unless you have created a user-defined function named of that name, since that's not a builtin function of MySQL). The query with theLIKEcomparison will execute, but it's not going to return any rows. It doesn't matter what value is found in thetitlecolumn, the comparison never going to find a literal percent character'%'at the as the first character in the literal string'ABC...'. (The percent character is only a wild card when it appears in the string on the right side of the LIKE comparison.)