gpt4 book ai didi

mysql - 在mysql的select查询中编写last()函数

转载 作者:行者123 更新时间:2023-11-29 21:28:11 24 4
gpt4 key购买 nike

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

谁能告诉我此查询中的错误吗?我不断得到:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(hr_leave.fromdate) AS lastdate from hr_leave) FROM hr INNER JOIN hr_lea' at line 1

最佳答案

现在mysql中已经没有像last这样的东西了,不, http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html

因此要获得所需的结果,请使用查询。 SELECT 列名 FROM 表名 ORDER BY 列名 DESC LIMIT 1

关于mysql - 在mysql的select查询中编写last()函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35407293/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com