mysql - 一个简单的hql查询语句问题
大家讲道理
大家讲道理 2017-04-17 13:23:19
0
1
273

有一张用户教育经历的数据表,就是类似那种小学6年,初中3年,高中3年的教育经历。
表中有字段
useId, 外键关联到user用户信息表
beginTime, 教育经历开始时间
endTime, 教育经历结束时间
school, 接受教育的学校
现在已知张三的useId=100,我想得到张三最近的接受教育的学校,也就是查询出在userId=100的条件下beginTime最靠近今天的数据,hql语句该如何写?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
小葫芦
SELECT `school` 
FROM `table` 
WHERE userId = 100 AND beginTime = max(beginTime)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!