我很难从连接中的第二个表定义变量。
这是我的代码
$sql = "SELECT *
FROM Catalog
LEFT OUTER JOIN Client_Data on CatalogMgr.partnumber = Client_Data.partnumber
LEFT OUTER JOIN Clients on Client_Data.Client_id = Clients.Client_Id
LEFT OUTER JOIN Clients C1 on Clients.Client_Name = C1.Client_Name
WHERE Clients.Client_Id = '".$C_ID."'
AND Avail_Flag = 10";
$CL_Name = Clients.Client_Name;
//结果
$ result = mysql_query($ sql);
while ($row = mysql_fetch_array($result))
====在输出页面
echo "$CL_Name";
是空的。
====我试过了
$CL_name = $row['Clients.Client_Name'];
$CL_name = $row['Client_Name'];
并且都返回一个空变量。
感谢您的帮助。
答案 0 :(得分:0)
第一个LEFT OUTER JOIN看起来错了。 CatalogMgr
=> Catalog
?
答案 1 :(得分:0)
为什么不选择这样
$sql = "SELECT Catalog.* , Client_Data.name as `Client_Name`
FROM Catalog
LEFT OUTER JOIN Client_Data on CatalogMgr.partnumber = Client_Data.partnumber
LEFT OUTER JOIN Clients on Client_Data.Client_id = Clients.Client_Id
LEFT OUTER JOIN Clients C1 on Clients.Client_Name = C1.Client_Name
WHERE Clients.Client_Id = '".$C_ID."'
AND Avail_Flag = 10";
$CL_Name = Clients.Client_Name;
用这样的php回音
echo $row['Client_Name'];