
select * from( SELECT year(now())-year(t_date) as t_year FROM `test_t` where year(t_date) >1990 ) as tmp_data where t_year >10
====================
说明一下思路:
子查询计算出入职的年数,并将结果添加字段别名t_year,这个语句只select了t_date字段,其他字段请按需要添加.
SELECT year(now())-year(t_date) as t_year FROM `test_t` where year(t_date) >1990
然后使用另一条查询来得到大于10年的职工.
select * from (子查询语句) as temp_data where t_year>10
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)