2016-02-26 117 views
0

所以我更新Virtuemart後,當我尋找在客戶網站的某個特定的產品我收到此錯誤:VirtueMart搜索錯誤

vmError: exeSortSearchListQuery Unknown column 'p.product_sku' in 'where clause'

SQL=SELECT SQL_CALC_FOUND_ROWS p.`virtuemart_product_id` 
FROM `tqmux_virtuemart_products` as p 
INNER JOIN `tqmux_virtuemart_products_en_gb` as l 
    using (`virtuemart_product_id`) 
LEFT JOIN `tqmux_virtuemart_product_manufacturers` 
    ON p.`virtuemart_product_id` = `tqmux_virtuemart_product_manufacturers`.`virtuemart_product_id` 
WHERE ((`l`.product_name LIKE "%anya%" 
     OR `product_sku` LIKE "%anya%" 
     OR `l`.`slug` LIKE "%anya%" 
     OR `l`.product_s_desc LIKE "%anya%" 
     OR `l`.`metadesc` LIKE "%anya%" 
     OR `p.product_sku` LIKE "%anya%" 
     OR `c.category_name` LIKE "%anya%" 
     OR `c.category_description` LIKE "%anya%" 
     OR `m.mf_name` LIKE "%anya%" 
     OR `p.product_name` LIKE "%anya%" 
     OR `p.product_s_desc` LIKE "%anya%") 
    AND `tqmux_virtuemart_product_manufacturers`.`virtuemart_manufacturer_id` = 1  
    AND p.`virtuemart_vendor_id` = "1") 
group by p.`virtuemart_product_id` 
ORDER BY p.`created_on` DESC, `virtuemart_product_id` DESC 
LIMIT 0, 20 

誰能幫助我?謝謝。

UPDATE

enter image description here

+0

你能告訴我們什麼表tqmux_virtuemart_products有它(DDL)嗎?該錯誤暗示列product_Sku在該表中不存在。此外,爲什麼你在哪裏有'product_Sku'和'p.product_Sku'?第一個產品_Sku來源於哪個表格?最後的表別名'p','l'好像存在哪裏是'c','m'來自哪裏? – xQbert

+0

我不自己構建查詢,VM自己完成。我會將表格的圖像附加到上面的問題上。 – PatrickMelia

+0

@xQbert如果你不介意我問,你會發現問題是什麼?我一直在努力嘗試,並沒有得到任何地方。 – PatrickMelia

回答

0

我一般只用backtic只有當我不得不這樣做。如列名或保留字列名中的空格,否則將它們放在外面以便讀取,因此不會遇到這些類型的錯誤。

`p.product_sku` 

should be 

`p`.`product_sku` 

所以......

SELECT SQL_CALC_FOUND_ROWS p.virtuemart_product_id 
FROM tqmux_virtuemart_products as p 
INNER JOIN tqmux_virtuemart_products_en_gb as l 
    using (virtuemart_product_id) 
LEFT JOIN tqmux_virtuemart_product_manufacturers tvpm 
    ON p.virtuemart_product_id = tvpm.virtuemart_product_id 
WHERE ((l.product_name LIKE "%anya%" 
     OR product_sku LIKE "%anya%" 
     OR l.slug LIKE "%anya%" 
     OR l`.product_s_desc LIKE "%anya%" 
     OR l`.`metadesc LIKE "%anya%" 
     OR p.product_sku LIKE "%anya%" 
     OR c.category_name LIKE "%anya%" 
     OR c.category_description LIKE "%anya%" 
     OR m.mf_name LIKE "%anya%" 
     OR p.product_name LIKE "%anya%" 
     OR p.product_s_desc LIKE "%anya%") 
    AND tvpm.virtuemart_manufacturer_id = 1  
    AND p.virtuemart_vendor_id = "1") 
group by p.virtuemart_product_id 
ORDER BY p.created_on DESC, virtuemart_product_id DESC 

我也想知道爲什麼

  OR p.product_sku LIKE "%anya%" 
and   OR product_sku LIKE "%anya%" 

都在查詢中。他們似乎也做同樣的事情。

+0

好吧。我可以在哪裏訪問該文件來改變它?我從來沒有改變過這段代碼。我最近做的更新virtmart,更新數據庫等,就是這樣。 – PatrickMelia

+0

我可以在哪裏找到文件@xQbert的更新。 – PatrickMelia

+0

擺脫我的專業知識:http://forum.virtuemart.net/index.php?topic=115951.0顯示或可能:https://virtuemart-manager.com/useful-articles/tips-tricks/what-are- custom-sqls-how-to-manage-virtuemart-data-using-them /我自己並沒有使用virtmart,但仔細看看缺少的SQL,或者不正確放置的刻度是導致問題的原因。你能刪除並重新添加生成這個SQL的元素嗎?簡單地說:'p.product_name'不是列名,它是一個表&列名。我們需要消除後面的勾號,或者確保它們放在每個字符串周圍而不是點。 – xQbert