2013-02-05 23 views
0

你好我想如下因素的腳本來從Magento的數據庫中的數據,但我grttinf如下因素誤差誤差在MySQL語法在Magento

您的SQL語法錯誤;檢查對應於你的MySQL服務器版本使用附近的正確語法手冊「:描述--104:元描述--506:的Anahi的提示--1067:大小&飛度」在第15行

$conn1 = mysql_pconnect("db.aviesta.com","gys",'d3v3l0p3r$') or die ("Error In Connetion Databse" . mysql_error()); 
mysql_select_db("customer_transaction_dev",$conn1); 
//db Connection end 
$select=mysql_query("SELECT DISTINCT A.entity_id AS productID, 
A.sku, A.created_at, B.value AS Price, 
C.value AS Description, 
E.qty AS Quantity, 
F.stock_status, 
H.Value AS imageURL 
FROM catalog_product_entity A 
INNER JOIN catalog_product_entity_decimal B 
ON A.entity_id=B.entity_id AND B.store_id=5 
INNER JOIN catalog_product_entity_varchar C 
ON A.entity_id=C.entity_id AND C.attribute_id=105 --Description 
INNER JOIN catalog_product_entity_text D 
ON A.entity_id=D.entity_id 
AND D.attribute_id= 97 
--97: Description 
--104: Meta Description 
--506: Anahi's Tip 
--1067: Size & Fit 
--1068: Style Ideas 
INNER JOIN cataloginventory_stock_item E 
ON A.entity_id=E.product_id 
INNER JOIN cataloginventory_stock_item F 
ON A.entity_id=F.product_id AND F.website_id=2 
INNER JOIN catalog_product_relation G 
ON A.entity_id=G.parent_id 
INNER JOIN catalog_product_entity_varchar H 
ON A.entity_id=H.entity_id 
AND H.attribute_id =106 --Image 
WHERE A.attribute_set_id IN (70,71) 
AND A.entity_id=26179' ") or die(mysql_error()); 

請告訴我我在做什麼錯誤

回答

3

雙點劃線註釋需要以下空格。

WRONG:

--97: Description 

RIGHT:

-- 97: Description 

http://dev.mysql.com/doc/refman/5.5/en/comments.html


回覆您的評論:

WHERE A.attribute_set_id IN (70,71) 
AND A.entity_id=26179' 

您在查詢的第30行的WHERE子句末尾有一個零散的單引號。 SQL語法分析器從SQL語句的開始處開始計算行數,而不是從文件的開始處開始計算。


其中Image發生的唯一的地方是在這裏:

ON A.entity_id=H.entity_id 
AND H.attribute_id =106 --Image 

這是你所需要的雙橫線註釋後的空間另一種情況。

似乎也可以在查詢前面多了一個這樣的案例:

ON A.entity_id=C.entity_id AND C.attribute_id=105 --Description 

我測試的查詢對一些空表,有一次我通過添加空格糾正所有意見,查詢工作。

+0

現在它會引發此錯誤您的SQL語法中有錯誤;檢查對應於你的MySQL服務器版本的手冊,在第30行第30行'''附近使用正確的語法。A.antity_id = E.product_id在我的文件中 –

+0

我認爲迄今爲止您提供的解決方案非常棒,但是現在我在'on子句'錯誤中遇到了未知列'Image' –