我有一个查询在zend framework 2中没有运行它的show unknown列my query

$select = new Select('dining_table_reservation');
        $select->columns(array('range'=>new \Zend\Db\Sql\Expression("CONCAT(5*floor(dining_table.SeatingCapacity/5),'-',5*floor(dining_table.SeatingCapacity/5) + 5)"),'Avgtime'=>new \Zend\Db\Sql\Expression('avg(timestampdiff(SECOND, '.$dtr.'.StartTime, '.$dtr.'.EndTime))')));
        $select->join($dt, "$dtr.TableId=$dt.TableId", array('SeatingCapacity'),'INNER');
        $select->group(1);
        $select->order($dt.'.SeatingCapacity');

我的查询外观
SELECT CONCAT(5*floor(dining_table.SeatingCapacity/5),'-',5*floor(dining_table.SeatingCapacity/5) + 5) AS "range", avg(timestampdiff(SECOND, dining_table_reservation.StartTime, dining_table_reservation.EndTime)) AS "Avgtime", "dining_table"."SeatingCapacity" AS "SeatingCapacity" FROM "dining_table_reservation" INNER JOIN "dining_table" ON "dining_table_reservation"."TableId"="dining_table"."TableId" GROUP BY "1" ORDER BY "dining_table"."SeatingCapacity" ASC

显示错误:
“无法执行语句(42S22-1054-未知列
\ U00271\U0027在\U0027组语句中\U0027“
我该怎么办?

最佳答案

数据库中的表中没有列1,需要为GROUP BY设置EXIST列。你可以展示你的数据库结构吗?

10-08 04:00