title: UNION SQL statement not working
body: <p>Why is this wrong and how can I put it right?</p>
  
  <pre><code>SELECT     PublicationID
  FROM         (SELECT DISTINCT pat.PublicationID
                         FROM          dbo.PubAdvTransData AS pat INNER JOIN
                                            dbo.PubAdvertiser AS pa ON pat.AdvTransID =   pa.AdvTransID
                         WHERE      (pat.LastAdDate &gt; '7 / 1 / 2009') AND (pat.PublicationID = 29171)) AS table1
  UNION
  SELECT     PublicationAreaBuy.AreaBuyID AS PublicationID
  FROM         PublicationAreaBuy INNER JOIN
                        table1 AS table1_1 ON table1.publicationID =     PublicationAreaBuy.PublicationID
  </code></pre>
  
  <p>The error is that table1 is an invalid object.</p>
  
  <p>Thanks.</p>