我在2张桌子上创建了。这些表是Department,employee。
现在我想在部门表中分配外键,并在员工表中分配加入。
有什么想法??
SELECT id,department FROM department;
SELECT * FROM `employee'
答案 0 :(得分:3)
create employee table field are- id(primary key),name,dept_id
department table fields are-dept_id(primary key),name
答案 1 :(得分:0)
你在找这个: -
$query="select emp.name, dep.department from employee emp
INNER JOIN
department dep ON
emp.department=dep.department
order by emp.name asc";