title: Ignore SQL INNER JOIN if there are no records to join?
body: <p>I have the following Join</p>
  
  <pre><code>INNER JOIN @SynonymTable AS A ON ([Products].[Title] LIKE A.[Synonym])
  </code></pre>
  
  <p>The @SynonymTable table variable contains (if needed) a list of items terms such as:</p>
  
  <pre><code>%shirt%
  %blouse%
  %petticoat%
  </code></pre>
  
  <p>These are all based on a list of a synonyms for a particular keyword search, such as the term 'shirt' - from this I can then find all items that may be related, etc.  The problem is that if the there is no keyword supplied the query obviously does not join anything.</p>
  
  <p>Is there anyway to eliminate the join or return all items if there are no items in the synonym table?</p>
  
  <p>I've found posts such as <a href="https://stackoverflow.com/questions/3830619/bypass-last-inner-join-in-query">Bypass last INNER JOIN in query</a> but am unable to get it to work for my scenario?</p>
  
  <p>Any help or advice would be great.</p>