title: Extract specific words from text field in mysql
body: <p>I have a table that contains a text field, there is around 3 to 4 sentences in the field depending on the row.</p>
  
  <p>Now, I am making an auto-complete html object, and I would like to start typing the beginning of a word and that the database return words that start with those letters from the  database text field.</p>
  
  <p>Example of a text field: I like fishsticks, fishhat are great too</p>
  
  <p>in my auto-complete if I would type "fish" it would propose "fishsticks" and "fishhat"</p>
  
  <p>Everything works but the query.</p>
  
  <p>I can easily find the rows that contains a specific word but I can't extract only the word, not the full text.</p>
  
  <pre><code>select data_txt from mytable match(data_txt) against('fish', IN BOOLEAN MODE) limit 10
  </code></pre>
  
  <p>I know it is dirty, but I cannot rearrange the database.</p>
  
  <p>Thank you for your help!</p>
  
  <p>EDIT:</p>
  
  <p>Here's what I got, thanks to Brent Worden, it is not clean but it works:</p>
  
  <pre><code>SELECT DISTINCT
  SUBSTRING(data_txt, 
  LOCATE('great', data_txt),
  LOCATE(' ' , data_txt, LOCATE('great', data_txt)) - LOCATE('great', data_txt)
  )
   FROM mytable WHERE data_txt LIKE '% great%'
  LIMIT 10
  </code></pre>
  
  <p>any idea on how to avoid using the same <code>LOCATE</code> expression over and over?</p>