我嘗試寫一個SQL代碼加入三個表在一起,但它始終顯示手動你的SQL語法有錯誤;檢查對應於你的MySQL服務器版本正確的語法使用近'假入JOIN
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
'leave l JOIN employee e ON l.Emp_ID=e.Emp_ID JOIN department d ON e.Dept_ID= d.D' at line 1
這裏是我的代碼
<?php
include("conn.php");
SESSION_START();
$aid = $_SESSION["eid"];
$check_user=mysql_query("select * from employee where Emp_ID='$aid'");
$row=mysql_fetch_assoc($check_user);
$leave = mysql_query("select * from leave");
$_GET['Leave_ID'] = $leave['Leave_ID'];
$leaveID = $_GET['Leave_ID'];
?>
<?php
$sql = mysql_query("select e.Emp_Fname, e.Emp_ID, e.Emp_Email, e.ContactNo_HP, e.ContactNo_Home, l.Date_Apply, l.Leave_Type, l.Leave_Start, l.Leave_End, l.Leave_Reason FROM leave l JOIN employee e ON l.Emp_ID=e.Emp_ID JOIN department d ON e.Dept_ID= d.Dept_ID where l.Leave_ID = $leaveID");
if($sql == FALSE)
{
die(mysql_error());
}
$rows = mysql_fetch_assoc($sql);
?>
請做一些調試。這裏有幾個代碼,有3個查詢。刪除一些查詢。檢查什麼查詢會產生錯誤。不要只是在這裏轉儲你的代碼,做一些調查 – Nanne