title: mysql find records that contain words from a different table?
body: <p>SCENARIO:</p>
  
  <p>I have one large table (let's call it "WordTable") with a list of words (let's call the field "theWord") that could have 10,000+ records.</p>
  
  <p>I also have a large table (let's call it "MySentences") with a <code>VARCHAR</code> field (let's call the field "theSentence") that contains many varied sentences - it could have millions of records.</p>
  
  <p>QUESTION:
  What SQL could I write for the <code>MySQL database</code> to give me a list of which records in <code>MySentences.theSentence</code> contain any of the words from <code>WordTable.theWord</code> ?</p>
  
  <p>Since there are many records in both tables, using numerous Like statements is not feasible.  Would FullText Search allow some capability here?</p>
  
  <p>Hopefully this helps...  by the way, a "sentence" does not always need to have spaces... it could just be a collection of letters</p>
  
  <p>Here are some MySQL scripts to illustrate the scenario:</p>
  
  <pre><code>CREATE TABLE `MySentences` (
    `id` int(11) NOT NULL,
    `theSentence` varchar(1000) NOT NULL
  ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
  
  INSERT INTO `MySentences` (`id`, `theSentence`) VALUES
  (1, 'hereisatestsentence'),
  (2, 'asdfasdfadsf'),
  (3, 'today is a blue sky'),
  (4, 'jk2k2lkjskylkjdsf'),
  (5, 'ddddddd'),
  (6, 'nothing'),
  (7, 'sometest');
  
  CREATE TABLE `WordTable` (
    `id` int(11) NOT NULL,
    `theWord` varchar(50) NOT NULL
  ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
  
  INSERT INTO `WordTable` (`id`, `theWord`) VALUES
  (1, 'test'),
  (2, 'house'),
  (3, 'blue'),
  (4, 'sky');
  
  ALTER TABLE `MySentences`
    ADD PRIMARY KEY (`id`);
  
  ALTER TABLE `WordTable`
    ADD PRIMARY KEY (`id`);
  
  ALTER TABLE `MySentences`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8;
  
  ALTER TABLE `WordTable`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
  </code></pre>