Hello ,
I am working in a project of employees Attendance in Java ( NetBeans ) , I have created two tables, one for employee's data and the other to check the attendance.
Now I want to link the primary key of the first table to the second table but I do not know how . for example if you want to check the attendance it will show you the ID of the employee and when ( time in / time out )
could you help me, please?
Thank you
What I have tried:
this is the first table
create table employee(empID int primary key
auto_increment , fName varchar(100),
civilId int ,mobile int );
the second table
create table employeeAttendance (
id int primary key auto_increment ,
empID int not null,timeIn time ,timeOut time ,
daay date,
constraint emp_fk foreign key (empID) references employee(empID)
);
and in Java I did that but could not complete it :
String sql="insert into employeeAttendance(empID,timeIn,daay)values(?,?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,.getText());
pstmt.setString(2,timeLabel.getText());
pstmt.setString(3,dateLabel.getText());