title: MYSQL like + group
body: <p>Well I'm having a problem mainly caused by bad structure in database. I'm coding this for a company whose code is quite messy and the table is very large so I don't think it's an option to fix the structure.</p>
  
  <p>Anyway, my issue is that I'm trying to somehow group a value that won't be alone in the string...
  They are storing values separated with commas... So it would be like</p>
  
  <pre><code>field: "category" value: 'var1, var2, var3'
  </code></pre>
  
  <p>And I will search using this query:</p>
  
  <pre><code>SELECT name, category 
  FROM companies 
  WHERE (MATCH(name, category) AGAINST ('$search' IN BOOLEAN MODE) 
         OR category LIKE '$search%')
  </code></pre>
  
  <p>It would match with for example var2 (it's not limited to 3 variables though, can be solo or many more) and I'd split it manually in PHP, no problem. Although I will not get enough matches, I want e.g. 10 matches by different searches. To be more specific I'm making an autosuggest feature, which means I will for example want to match "moto%" with motorbike, motor alone or whatever but I keep getting the same values, like there'd be a couple of 100 of results that contains "motorbike" and I don't know how to filter them, as I'm not able to use GROUP BY due to bad db structure...</p>
  
  <p>I found this: <a href="https://stackoverflow.com/questions/1647736/t-sql-group-by-with-like-is-this-possible">T-SQL - GROUP BY with LIKE - is this possible?</a>
  It SEEMED as something that would be a solution, but as far as I've tried I could not get it work with what I wanted.</p>
  
  <p>So I'm wondering which solutions there are... If there are ABSOLUTELY no way of working this around I might probably have to fix the db structure (but this really has to be the last option)</p>