Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想获得 60 岁或以上的人的姓氏、生日和年龄。到目前为止,这就是我的做法:
Select * FROM ( SELECT TIMESTAMPDIFF(YEAR,bdate,CURDATE()) AS age FROM employee ) AS d WHERE age>=60
它可以工作,但是如果我输入 lname,bdate 而不是 *,我会得到一个错误。" '字段列表' 中的未知列 'lname'。" 我不太清楚如何获取姓氏和生日,而且我一直收到同样的错误。
您的派生表仅包含名为“年龄”的列;试试这个:
Select * FROM employee WHERE TIMESTAMPDIFF(YEAR,bdate,CURDATE())>= 60