SELECT hr.*,hr_leave.*,(SELECT LAST(hr_leave.fromdate) AS lastdate from hr_leave)
FROM hr
INNER JOIN hr_leave
ON hr.id=hr_leave.hrid
WHERE hr.oid=4 AND hr.ouid=1
ORDER BY
hr_leave.hrid,hr_leave.fromdate
GROUP BY hr_leave.from
有人能告诉我这个查询中的错误吗?我一直在说:
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'(hr_leave.fromdate)AS last_ate from hr_leave附近使用正确的语法 从小时 INNER JOIN hr_lea'在第1行
答案 0 :(得分:0)
现在没有像mysql中的最后一样,不, http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
所以为了获得理想的结果,请使用查询。 SELECT column_name FROM table_name ORDER BY column_name DESC LIMIT 1