1

这是我的 SQL;

SELECT
    cs.name,
    ct.name AS type,
    cr.date,
    cr.hg_version,
    cr.public,
    cr.tag,
    cr.reference,
    cr.description
FROM changelog_systems cs
LEFT JOIN changelog_rows cr ON cr.changelog_system_id = cs.id
LEFT JOIN changelog_types ct ON ct.id = cr.type_id
GROUP BY name
ORDER BY cr.date ASC

问题是我的系统没有最新日期;相反,它只是获取在GROUP BY.

4

1 回答 1

1

Actually your query is wrong altogether. You cannot use non aggregate columns in your SELECT clause. You group by name and all the other columns in your SELECT clause are not grouped by. MySQL will still accept this (wrong) query if you don't have the option ONLY_FULL_GROUP_BY set, but it doesn't make it any less wrong. So what you should do is rewrite the query so it does give you a predictable result. For more info see: http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html#sqlmode%5Fonly%5Ffull%5Fgroup%5Fby

于 2013-06-11T21:06:38.050 回答