0

If I have such as table below

|---col_1---|---col_2-----|
|---19------| "A; E; C; H"|
|---23------| "B; E; C"   |
|---24------| "O; D"      |

where col_2 is GROUP_CONCATed (by semicolon) column and I'm passing "E; A; C", I want to SELECT 19, 23 because at least 1 word (separated with semicolon) matches.

Can not figure out how to do it as MySQL query?

P.S.: This will be used in SphinxQL (Sphinx search engine Query Lang), which is similar to MySQL.

Novitoll
  • 820
  • 1
  • 9
  • 22
  • 2
    Simple. Don't have a "GROUP_CONCATenated column" (whatever that is). – Strawberry Jul 27 '17 at 10:35
  • I'm tempted to vote to close this question as "too broad". Doing waht you ask -- searching a denormalized column (GROUP_CONCATed) with a denormalized search term -- is **very hard** to do in pure MySQL query language. It will take dozens of poorly performing lines of query language. If you can normalize your data, spend your effort doing that. If you can't, look at `SUBSTRING_INDEX()` https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_substring-index. Or, maybe, look at the ads in the right column of this fine web site. :-) – O. Jones Jul 27 '17 at 10:50
  • thanks, guys, I've already been given answer I want. please take a look at this forum's answer. I'm closing this. http://sphinxsearch.com/forum/view.html?id=15476 – Novitoll Jul 27 '17 at 11:03

0 Answers0