您好,我想从出生日期列中的30-50岁之间的年龄表中选择数据。
SELECT * FROM
(SELECT FLOOR((CAST (GetDate() AS INTEGER) - CAST(dob1 AS INTEGER)) / 365.25) AS Age, *
from tbl_travelins) as tbl_travelins
WHERE Age >= 30 AND Age < 50
答案 0 :(得分:1)
尝试使用TIMESTAMPDIFF
:
SELECT *
FROM tbl_travelins
WHERE TIMESTAMPDIFF(YEAR, dob1, CURDATE()) BETWEEN 30 AND 49;