0

我很难从连接中的第二个表定义变量。

这是我的代码

$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'];

并且都返回一个空变量。

谢谢你的帮助。

4

2 回答 2

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

echo $row['Client_Name'];
于 2012-04-07T06:45:37.503 回答
0

第一个 LEFT OUTER JOIN 看起来不对。 CatalogMgr=> Catalog?

于 2012-04-06T22:31:52.530 回答