我在“用户”表中有此行:
id = 1;
birthdate(date) = 1992-02-12;
joined(int) = 2000;
我想创建这样的东西:
SELECT
CAST(birthdate as INT(4)) as birthyear, joined
FROM
users
WHERE
(birthyear - joined >= 20)
谁能给我一个提示/提示?提前致谢。
最佳答案
我认为您需要功能year()
:
select year(birthdate) as birthyear, joined
from users
where year(birthdate) - joined >= 20
关于mysql - 想要在SQL列中使用数学,但不是INT,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14989007/