i have two tables, employee details table(empno, emp_name , branch) and attendance table(date, Ot, attendence). I want to create a relation between two tables
Basically for this case you cannot. Your two tables must have something in common so that you can make one table related to the other one.
In this case, you probably need to add additional columns in the attendance table to indicate the attendence record belonging to which employee. For example, add "empno" column in the attendence table, and then set this "empno" as a foreign key of the employee details table by:
ALTER TABLE attendance ADD FOREIGN KEY (empno) REFERENCES employee_details(empno);
The SQL script may differ depending on which SQL database you're using.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.