title: SQL Union query - Multiple tables
body: <p>I have 2 tables (Projects and Documents), both have an ID and Name field.</p>
  
  <p>I'm looking for a query that meets the following requirments:
  - it will return rows from either table that have specfied words in the 'Name' field
  - it will return 3 fields: ID, Name and TableName -- where the tablename will be either be the name of the table or some identifier</p>
  
  <p>I tried:</p>
  
  <pre><code>SELECT id, name 
  FROM projects UNION SELECT id, name FROM documents
  WHERE name like '%querystriong%'
  </code></pre>
  
  <p>But this query does not add the 3rd (TableName) field and it returns rows from the Projects table that that have associated documents with querystring in the name field.</p>
  
  <p>I'm suspecting I'm tackling this completely wrong.  Any ideas?</p>