0
我有以下MySQL查詢MySQL錯誤1064,但不是一個保留字
SELECT REPLACE(book.title,'','') AS "item-name", REPLACE(inventory.sku,'','') AS "sku", REPLACE(IF(inventory.sku IN (SELECT sku FROM qty_skus) , (SELECT qty_skus.quantity FROM qty_skus WHERE qty_skus.sku = inventory.sku LIMIT 1), inventory.quantity),'','') AS "quantity",
REPLACE(LEFT(CONCAT(IF(book_type.book_text IS NOT NULL, CONCAT(book_type.book_text," "), ""), IFNULL(defect.defect,""), " ", IFNULL(inventory.additional_note,""), " ", IFNULL(feature.feature, ""), " ", IFNULL(water.feature, ""), " ", IFNULL(note.note,""),
" "), 2000),'','') AS "item-note",
REPLACE(IF(book.weight>3.99, "1", "2"),'','') AS "will-ship-internationally", REPLACE(inventory.isbn13,'','') AS "product-id", REPLACE(inventory.ourPrice,'','') AS "price",
REPLACE(IF(book.weight>4.8 AND (inventory.ourPrice - inventory.cost) < 9, "n", "y"),'','') AS "expedited-shipping", REPLACE(book_condition.book_condition,'','') AS "item-condition",
REPLACE(concat(location.location,IF(inventory.fixed="1", " Fixed", "")),'','') AS "Location", REPLACE(book.author,'','') AS "author", REPLACE(book.publisher,'','') AS "publisher",
REPLACE(IF(book_condition.book_condition="New", "11", IF(book_condition.book_condition="Fine", "1", IF(book_condition.book_condition="Very Good", "2", IF(book_condition.book_condition="Good", "3", IF(book_condition.book_condition="Poor", "4", ""))))),'','') AS "condition-id",
REPLACE(IF(inventory.cost < ((follette_title.usedbuying_price *1.37) OR (amtext.price*1.37) OR (nebraska.price *1.2) OR (tichenor.price *1.25)),IF(feature.book_type_3 = "DMG",inventory.cost,
IF(book_condition.book_condition="Good",inventory.cost,
IF(book_condition.book_condition="Poor",inventory.cost,IF(inventory.book_type_id = 3, inventory.cost,
IF(inventory.commission_level = 1, IF(inventory.cost < ((follette_title.usedbuying_price *1.71) OR (amtext.price*1.71)),(max((follette_title.usedbuying_price*1.71) OR (amtext.price*1.71)),inventory.cost),
(max((follette_title.usedbuying_price*1.37) OR (amtext.price*1.37) OR (nebraska.price *1.2) OR (tichenor.price *1.25))))))))),inventory.cost),'','') AS "Cost",
REPLACE(concat(IFNULL(buyer_type.buyer_type, ""),IFNULL(source.source, ""),IFNULL(inventory.source_date, ""),IFNULL(note.book_type_2, ""),IF(inventory.csmt=1, "CSMT", ""),IF(inventory.cu=1, "CU", ""),IF(inventory.manual=1, "manual", ""),IFNULL(book_type.book_code, ""),IF(water.book_type_4="WATER", "WATER", "")),'','') AS "Source", REPLACE(book.pub_date,'','') AS "pubdate", REPLACE(book.binding,'','') AS "Media", REPLACE(book_condition.book_condition,'','') AS "condition",
REPLACE(IF(location.location="FBA", "AMAZON_NA", ""),'','') AS "fulfillment-center-id"
FROM inventory
LEFT JOIN defect ON inventory.defect_id = defect.defect_id
LEFT JOIN book_condition ON defect.condition_id = book_condition.condition_id
LEFT JOIN book_type ON inventory.book_type_id = book_type.book_type_id
LEFT JOIN book ON inventory.isbn13 = book.isbn13
LEFT JOIN feature ON inventory.feature_id = feature.feature_id
LEFT JOIN water on inventory.additional_feature = water.feature_id
LEFT JOIN note ON inventory.note_id = note.note_id
LEFT JOIN location ON inventory.location_id = location.location_id
LEFT JOIN source ON inventory.source_id = source.source_id
LEFT JOIN buyer_type ON source.buyer_type_id = buyer_type.buyer_type_id
LEFT JOIN follette_title on inventory.isbn13 = follette_title.isbn13
LEFT JOIN amtext on inventory.isbn13 = amtext.isbn13
LEFT JOIN nebraska on inventory.isbn13 = nebraska.isbn13
LEFT JOIN tichenor on inventory.isbn13 = tichenor.isbn13
WHERE inventory.upload = 1 AND inventory.ourPrice > 0 AND inventory.location_id > 0 limit 0,20
而且我收到以下錯誤,我想不通爲什麼:
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))))),inventory.cost),'','') AS "Cost", REPLACE(concat(IFNULL(buyer_type.' at line 12
我看着在錯誤指示的保留字上,但我沒有看到成本作爲保留字。幫幫我!!!!
你不能弄清楚,因爲你怎麼能看這個查詢?你應該嘗試格式化它,因爲很可能你錯過了一些括號或其他語法錯誤。例如,您在那裏混合了雙引號和單引號:'CONCAT(book_type.book_text,「」)',應該是'CONCAT(book_type.book_text,'')',並且這已遍佈您的查詢 – Lamak
謝謝,但我掐了這個,需要儘快修復它。我把它作爲一個php的查詢,所以我可以檢查括號,他們似乎都匹配,因爲他們應該 – Jim
反應所有的表和字段名稱。那麼,如果您使用保留名稱,則無關緊要。 – Spudley