大家好,这是我第一次处理内部连接,非常感谢任何帮助。
只是想知道为什么我从我创建的代码中收到以下错误:
不是唯一的表/别名:“产品”
这是代码本身:
mysql_select_db($database_reps, $reps);
$query_orders = sprintf("SELECT
orders.ID AS mainID,
customers.`Name` AS customerName,
products.ProductName AS product,
orders.Quantity AS Quantity,
orders.comment As comment,
orders.SalesPrice AS SalesPrice,
orders.Price AS Price,
orders.paid AS paid,
orders.product2 AS product2,
orders.AgeOfPayment AS AgeOfPayment,
orders.orderDate AS orderDate,
products.Price AS productPrice,
staff.StaffName AS staffMember,
orders.bonus AS bonus
FROM
orders
INNER JOIN staff AS staff ON orders.staffMember = staff.ID
INNER JOIN products AS products ON orders.product = products.ID
INNER JOIN products AS products ON orders.product2 = products.ID
INNER JOIN customers AS customers ON orders.customerName = customers.ID
WHERE
orders.ID = %s", GetSQLValueString($colname_orders, "int"));
$orders = mysql_query($query_orders, $reps) or die(mysql_error());
$row_orders = mysql_fetch_assoc($orders);
$totalRows_orders = mysql_num_rows($orders);
连接被证明有点困难,但非常感谢任何帮助。