0
У меня есть следующий запрос MySQLMySQL Ошибка 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