JpaRepository,mysql数据库存在生日字段,根据年龄段查询信息
birthday为数据库的生日字段
主要应用了timestampdiff(year,日期,curdate() ) 方法
@Query(value = "select * from user where timestampdiff(year,birthday,curdate())>=?1 and timestampdiff(year,birthday,curdate())<=?2", nativeQuery = true)
Page<User> findByAgeBetween(Integer age, Integer age2, Pageable pageable);