title: MySql query error, can anyone equivalent query of this?
body: <p>I tried this</p>
  
  <pre><code>select posts.id, posts.title
  from posts
  inner join (
      select post_id,max(created)
      from comments
      group by post_id
      order by max(created) DESC ) as foo
  on posts.id=foo.post_id
  order by foo.max(created) DESC;
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>ERROR 1630 (42000): FUNCTION foo.max does not exist.
  Check the 'Function Name Parsing and Resolution' section in the Reference Manual
  </code></pre>
  
  <p>Tables</p>
  
  <pre><code>mysql&gt; describe comments;
  +----------+--------------+------+-----+---------+----------------+
  | Field    | Type         | Null | Key | Default | Extra          |
  +----------+--------------+------+-----+---------+----------------+
  | id       | int(11)      | NO   | PRI | NULL    | auto_increment |
  | post_id  | int(11)      | NO   | MUL | NULL    |                |
  | name     | varchar(255) | NO   |     | NULL    |                |
  | email    | varchar(255) | NO   |     | NULL    |                |
  | body     | varchar(500) | NO   |     | NULL    |                |
  | mark     | tinyint(4)   | NO   |     | 1       |                |
  | created  | datetime     | YES  |     | NULL    |                |
  | modified | datetime     | YES  |     | NULL    |                |
  +----------+--------------+------+-----+---------+----------------+
  8 rows in set (0.00 sec)
  
  
  
  mysql&gt; describe posts;
  +-------------+--------------+------+-----+---------+----------------+
  | Field       | Type         | Null | Key | Default | Extra          |
  +-------------+--------------+------+-----+---------+----------------+
  | id          | int(11)      | NO   | PRI | NULL    | auto_increment |
  | user_id     | int(11)      | NO   |     | NULL    |                |
  | title       | varchar(255) | NO   |     | NULL    |                |
  | body        | text         | YES  |     | NULL    |                |
  | category_id | int(11)      | NO   |     | NULL    |                |
  | tags        | varchar(50)  | NO   |     | NULL    |                |
  | mark        | tinyint(4)   | NO   |     | 1       |                |
  | created     | datetime     | YES  |     | NULL    |                |
  | modified    | datetime     | YES  |     | NULL    |                |
  +-------------+--------------+------+-----+---------+----------------+
  9 rows in set (0.00 sec)
  </code></pre>
  
  <p>I need to get the posts with latest comments.</p>