我正在使用 Symfony Project 1.4 和 Postgresql
我在教义中使用错误查询
$q = Doctrine_Query::create()
->select("count(sex) as total, sex")
->from('Biodata')
->groupBy('sex')
->execute();
调试时总是出现这样的显示错误:
SQLSTATE[42803]: Grouping error: 7 ERROR: column "e.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT e.id AS e__id, e.sex AS e__sex, COUNT(e.sex) AS e__0 ...
^. Failing Query: "SELECT e.id AS e__id, e.sex AS e__sex, COUNT(e.sex) AS e__0 FROM biodata e GROUP BY e.sex"
如何修复它并隐藏 e.id 列,这是错误还是需要技巧?
异常结果: