-4

我想在一页中加入 3 个表并显示它...

   $id = $_REQUEST["Emp_ID"];
   $test = mysql_query("select * from Employee left join department on employee.dept_id = department.dept_id 
                                               left join leave on employee.leave_id = leave_id where Emp_ID = $id");
   $row = mysql_fetch_assoc($test);
4

2 回答 2

1

您尝试Employee使用 name加入employee。如果这是您想要的,您首先需要创建一个别名。

 select * from Employee AS employee 
 left join department on employee.dept_id = department.dept_id 
 left join leave on employee.leave_id = leave.leave_id 
 where employee.Emp_ID = $id
于 2013-08-27T02:33:03.420 回答
-1

在来这里之前真的应该咨询谷歌。

SELECT t1.col, 
       t1.col,
       t2.col,
       t2.col,
       t3.col,
       t3.col
FROM    t1
    INNER JOIN t2 ON t2.foreignkey = t1.primarykey
    LEFT JOIN t3 on t3.foreignkey = t1.primarykey

如果你不能按照那个..谷歌。

于 2013-08-27T02:33:23.780 回答