錯誤:MySQL錯誤,我不指望
Unknown column 'miahrose_pos104.phppos_sales.item_id' in 'on clause'
我不認爲這應該發生,因爲我加入phppos_sales_items到phppos_items,但似乎查詢認爲它被連接到phppos_sales。我究竟做錯了什麼?
查詢:
CREATE TEMPORARY TABLE phppos_sales_items_temp
(SELECT date(sale_time) as sale_date, phppos_sales_items.sale_id, comment,payment_type, customer_id, employee_id, phppos_items.item_id, supplier_id, quantity_purchased, item_cost_price, item_unit_price, SUM(percent) as item_tax_percent, discount_percent, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as subtotal, ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(1+(SUM(percent)/100)),2) as total, ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*(SUM(percent)/100),2) as tax, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) - (item_cost_price*quantity_purchased) as profit FROM ((((
phppos_sales_items
INNER JOIN phppos_sales USING (sale_id))
INNER JOIN phppos_items USING (item_id))
LEFT OUTER JOIN phppos_suppliers ON phppos_items.supplier_id=phppos_suppliers.person_id) LEFT OUTER JOIN phppos_sales_items_taxes USING (sale_id, item_id))
GROUP BY sale_id, item_id)
雖然這樣做有什麼問題,但它在mysql 5中正常工作,在mysql 4中失敗。phppos_sales_items有一個sale_id和item_id – 2010-09-25 13:21:23
然後,版本4和版本5中的數據庫並不相同。或者在MySQL和版本4和5之間更改了某些內容,這些查詢在新版本中是非法的。 – duffymo 2010-09-25 13:51:31
看起來USING子句的某些地方改變了嘗試加入到上一個表的位置。有誰知道USING子句是否改變了? – 2010-09-25 14:15:37