另外,你不能使用SELECT后面的别名作为WHERE的条件,必须使用数据库表的字段作为条件,你要获取65岁以上的可以使用这样:
WHERE csrq<MAKEDATE(YEAR(NOW())-65, DAYOFYEAR(NOW()))
String sql = "SELECT * FROM teacher where to_char(sysdate,'yyyy')-to_char(birthday,'yyyy') = " +key+" \n"用
select date_format(from_days(to_days(now())-to_days(birthday)), '%Y'),date_format(from_days(to_days(now())-to_days(birthday)), '%m')把月也显示出来如果年是0 就显示月
或者
select if(to_days(now()) = to_days(birthday),concat(date_format(from_days(to_days(now())-to_days(birthday)),'年') ,concat(date_format(from_days(to_days(now())-to_days(birthday)),'月')) as a from ......
直接得出
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)