title: How do I combine 2 select statements into one?
body: <p>I am a noob when it comes to SQL syntax. </p>
  
  <p>I have a table with lots of rows and columns of course :P
  Lets say it looks like this:</p>
  
  <pre><code>      AAA BBB CCC DDD
  -----------------------
  Row1 | 1   A   D   X
  Row2 | 2   B   C   X
  Row3 | 3   C   D   Z
  </code></pre>
  
  <p>Now I want to create an advanced select statement that gives me this combined (pseudo SQLish here):</p>
  
  <pre><code>select 'Test1', * from TABLE Where CCC='D' AND DDD='X'
  select 'Test2', * from TABLE Where CCC&lt;&gt;'D' AND DDD='X'
  </code></pre>
  
  <p>The output would be:</p>
  
  <pre><code>Test1, 1, A, D, X
  Test2, 2, B, C, X
  </code></pre>
  
  <p>How would I combine those two select statements into one nice select statement?</p>
  
  <p>Would it work if I complicated the SQL like below (because my own SQL statement contains an exists statement)? I just want to know how I can combine the selects and then try to apply it to my somewhat more advanced SQL.</p>
  
  <pre><code>select 'Test1', * from TABLE Where CCC='D' AND DDD='X' AND exists(select ...)
  select 'Test2', * from TABLE Where CCC&lt;&gt;'D' AND DDD='X' AND exists(select ...)
  </code></pre>
  
  <p><br>
  <br>
  <br>
  My REAL SQL statement is this one:</p>
  
  <pre><code>select Status, * from WorkItems t1
  where  exists (select 1 from workitems t2 where t1.TextField01=t2.TextField01 AND (BoolField05=1) )
  AND TimeStamp=(select max(t2.TimeStamp) from workitems t2 where t2.TextField01=t1.TextField01) 
  AND TimeStamp&gt;'2009-02-12 18:00:00'
  </code></pre>
  
  <p>which gives me a result. But I want to combine it with a copy of this select statement with an added AND on the end and the 'Status' field would be changed with a string like 'DELETED'.</p>
  
  <pre><code>select 'DELETED', * from WorkItems t1
  where  exists (select 1 from workitems t2 where t1.TextField01=t2.TextField01 AND (BoolField05=1) )
  AND TimeStamp=(select max(t2.TimeStamp) from workitems t2 where t2.TextField01=t1.TextField01) 
  AND TimeStamp&gt;'2009-02-12 18:00:00'
  AND NOT (BoolField05=1)
  </code></pre>