title: How can i get records from my table there is more than 2 days old
body: <p>Why wont my interval day work in mysql statement.</p>
  
  <p>I want those who is more than 2 days old. This is how i tried.</p>
  
  <pre><code>SELECT t.*, ct.*,cd.*, max(t.transactiontime) as maxtime
  FROM exp_channel_titles as ct
  LEFT JOIN transactions as t on (ct.entry_id = t.restaurant_id)
  LEFT JOIN exp_channel_data as cd on (ct.entry_id = cd.entry_id)
  WHERE t.cardid &gt; 0 
  and maxtime &lt; ( CURDATE() - INTERVAL 2 DAY )
  and t.restaurant_id &gt; 0
  and ct.status= 'open'
  Group by ct.entry_id
  order by maxtime desc
  </code></pre>
  
  <p>This is my current output</p>
  
  <pre><code>TransactionID          Title           TransactionTime
  23132                  Locaton         2013-05-17 10:02:04
  23131                  Novuel          2013-05-16 16:26:45
  23128                  Mama Rosa       2013-05-15 14:42:44
  23126                  Rohan           2013-05-14 12:46:56
  </code></pre>
  
  <p>This is my desired output</p>
  
  <pre><code>TransactionID          Title           Date
  23128                  Mama Rosa       2013-05-15 14:42:44
  23126                  Rohan           2013-05-14 12:46:56
  </code></pre>
  
  <p>But i am getting this error</p>
  
  <pre><code>Error Number: 1054
  
  Unknown column 'maxtime' in 'where clause'
  
  SELECT t.*, ct.*,cd.*, max(t.transactiontime) as maxtime FROM exp_channel_titles as ct LEFT JOIN transactions as t on (ct.entry_id = t.restaurant_id) LEFT JOIN exp_channel_data as cd on (ct.entry_id = cd.entry_id) WHERE t.cardid &gt; 0 and maxtime &lt; ( CURDATE() - INTERVAL 2 DAY ) and t.restaurant_id &gt; 0 and ct.status= 'open' Group by ct.entry_id order by maxtime desc
  
  Filename: libraries/Functions.php(656) : eval()'d code
  
  Line Number: 46
  </code></pre>