cancel
Showing results for 
Search instead for 
Did you mean: 

SQLSTATE[42000]: Syntax error or access violation: 1064

SQLSTATE[42000]: Syntax error or access violation: 1064

Hi all,

I upgraded  the magento 2.2.4 to 2.2.6 . I faced the issue below

 

2 exception(s):
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42000]: Syntax error or access violation: 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 'AND mv.store_id=1) AND (stock_status_index.stock_status = 1) GROUP BY `entity_id' at line 5, query was: SELECT DISTINCT  `e`.*, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, `cat_index`.`position` AS `cat_index_position`, `mv`.*, MAX(logged_at) AS `max_loged`, COUNT(`event_id`) AS `num_view_counts`, `stock_status_index`.`stock_status` AS `is_salable` FROM `best_catalog_product_entity` AS `e`
 INNER JOIN `best_catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 INNER JOIN `best_catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id='2'
 LEFT JOIN `best_report_event` AS `mv` ON mv.object_id = e.entity_id
 INNER JOIN `best_cataloginventory_stock_status` AS `stock_status_index` ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (mv.event_type_id = 1 AND mv.subject_id= AND mv.store_id=1) AND (stock_status_index.stock_status = 1) GROUP BY `entity_id` ORDER BY `max_loged` DESC
 LIMIT 15
Exception #1 (PDOException): SQLSTATE[42000]: Syntax error or access violation: 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 'AND mv.store_id=1) AND (stock_status_index.stock_status = 1) GROUP BY `entity_id' at line 5

How can fix this issue?

1 REPLY 1

Re: SQLSTATE[42000]: Syntax error or access violation: 1064

This is theme issue. I just disable RecentlyViewed module. Its working for me..


@NavinMdr wrote:

Hi all,

I upgraded  the magento 2.2.4 to 2.2.6 . I faced the issue below

 

2 exception(s):
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42000]: Syntax error or access violation: 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 'AND mv.store_id=1) AND (stock_status_index.stock_status = 1) GROUP BY `entity_id' at line 5, query was: SELECT DISTINCT  `e`.*, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, `cat_index`.`position` AS `cat_index_position`, `mv`.*, MAX(logged_at) AS `max_loged`, COUNT(`event_id`) AS `num_view_counts`, `stock_status_index`.`stock_status` AS `is_salable` FROM `best_catalog_product_entity` AS `e`
 INNER JOIN `best_catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 INNER JOIN `best_catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id='2'
 LEFT JOIN `best_report_event` AS `mv` ON mv.object_id = e.entity_id
 INNER JOIN `best_cataloginventory_stock_status` AS `stock_status_index` ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (mv.event_type_id = 1 AND mv.subject_id= AND mv.store_id=1) AND (stock_status_index.stock_status = 1) GROUP BY `entity_id` ORDER BY `max_loged` DESC
 LIMIT 15
Exception #1 (PDOException): SQLSTATE[42000]: Syntax error or access violation: 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 'AND mv.store_id=1) AND (stock_status_index.stock_status = 1) GROUP BY `entity_id' at line 5

How can fix this issue?