0
我有一个右下面的查询上的“C”我subequery加入MySQL的RIGHT JOIN嵌套子查询
$sqlbsc="SELECT customers.LastName, Sum(IFNULL(scripts.PharmAmount,0)) AS SumPharm, customers.ChemistID, customers.FullName
FROM
(SELECT scripts.WrittenOff, scripts.PharmAmount, scripts.ChemistID, scripts.ReconcilID, claims.CustomerID FROM scripts
INNER JOIN
claims ON scripts.ClaimID = claims.ClaimID
WHERE
(((scripts.WrittenOff)=False) AND ((scripts.ChemistID)='".$_SESSION['chsh']."') AND ((scripts.ReconcilID) IS NULL))) c
RIGHT JOIN customers ON c.CustomerID = customers.CustomerID
GROUP BY customers.LastName, customers.ChemistID, customers.FullName
HAVING ((customers.ChemistID)='".$_SESSION['chsh']."')
ORDER BY customers.LastName";
这是
Customers.FirstName, Customers.LastName and Sum(Scripts.pharmamount) where Scripts.reconcilID IS NULL
结束了,但我想我所有的客户从我的客户表中出现,并且只显示为sum = $0.00
我有工作在Ms Access作为子查询,但上面没有给我什么。
我的结果对于我的子查询SQL是正确的。当我使用它它的作品,但我的主要查询不起作用。
任何人都可以提供一些见解吗?