2015-04-16 70 views
0

我該如何避免出現錯誤1060?MYSQL錯誤1060 - 重複列

CREATE VIEW `new-query` AS 

SELECT L1.Inv_Num, L1.Line_Num, P1.Prod_SKU, P1.Prod_Descript, 
L2.Line_Num, P2.Prod_SKU, P2.Prod_Descript, P1.Brand_ID 

FROM LGLINE L1, LGLINE L2, LGPRODUCT P1, LGPRODUCT P2 

WHERE P1.Prod_Category IN ('SEALER') AND P2.Prod_Category IN ('TOP COAT'); 
+0

爲'L2.Line_Num','P2.Prod_SKU','P2.Prod_Descript'創建別名 –

回答

0

您有兩次指定的相同列名,所以您需要將列名別名爲唯一名稱。我只是將l1_,l2_p1_和p2_添加到不止一次出現的列中。

CREATE VIEW new-query AS 
SELECT L1.Inv_Num, L1.Line_Num l1_line num, P1.Prod_SKU p1_prod_sku, P1.Prod_Descript p1_prod_descript, L2.Line_Num l2_line num, P2.Prod_SKU p2_prod_sku, P2.Prod_Descript p2_prod_descript, P1.Brand_ID 
FROM LGLINE L1, LGLINE L2, LGPRODUCT P1, LGPRODUCT P2 
WHERE P1.Prod_Category IN ('SEALER') AND P2.Prod_Category IN ('TOP COAT');