0
SELECT id, forename, surname, created 
FROM name n 
WHERE created = (SELECT MAX(created) 
                          FROM name 
                          GROUP BY id 
                          HAVING id = n.id);

架构.yml:

    id:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: true
      autoincrement: true
  lcreated:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
  forname/surname:
      type: integer(4)
      fixed: false
      unsigned: true
      primary: false
      notnull: true
      autoincrement: false

我确实有一个额外的名字和姓氏的表格!

我怎样才能将其转换为学说 1.2?

4

1 回答 1

0

试试这个:

$query = Doctrine_Query::create()
  ->from('Name m')
  ->where('m.created = (SELECT MAX(gn.created) 
                          FROM Name gn
                          GROUP BY gn.id 
                          HAVING m.id = gn.id)');

链接到文档

于 2012-07-23T11:54:10.000 回答