title: MySQL Split String To Return All Words in All Rows
body: <p>I have a stored procedure as documented in: <a href="http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/" rel="nofollow">http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/</a> to use MySQL's Substring() function to get each word in a string.  What I want is for the following query to return every word that appears in every row of the Sentences table.  Currently, I need to filter through position 1, 2, 3 etc.  But I don't know how many words a sentence might have, so that's very inefficient.  Any ideas for how to get all words in all sentences in one query?</p>
  
  <pre><code>SELECT DISTINCT SPLIT_STR(`SentenceText`, " ", 1) AS Word FROM `Sentences`;
  </code></pre>
  
  <p>As an example:
  If Sentences contained 2 rows:</p>
  
  <pre><code>this is a sentence
  sentence galore
  </code></pre>
  
  <p>I want a single query that returns:</p>
  
  <pre><code>this
  is
  a
  sentence
  galore
  </code></pre>