create table emp_details(
empId varchar(10),
empName varchar(20),
designation varchar(30),
band varchar(5),
joiningDate date,
);
insert into salary_struct.emp_details values
('E0001','abc','Trainee software engineer','E','2021-06-01'),
('C2002','xyz','senior business analyst','C2','2017-02-15');
如何在现有表中添加一个名为"经验"的新列,我想在其中添加加入日期和当前日期之间的差异(以年为单位(?
由于experience
列是一个动态计算的值,而不是将值存储在新的db列中,因此您可以很容易地在选定列中获得结果
select empId ,
empName ,
designation ,
band ,
joiningDate ,
DATEDIFF(curdate(), joiningDate)
from emp_details experience