hipeq Posted January 22, 2016 Share Posted January 22, 2016 Hello, When I click on Catalog -- Attachments I get the following error in my back office: Bad SQL queryYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'virtual ON a.id_attachment = virtual.id_attachment WHERE 1 ORDER ' at line 6 I run on a dedicated IIS server, PHP7 and MySQL 5.7 Everything else runs fine on this setup... Any thoughts? Thank you Link to comment Share on other sites More sharing options...
hipeq Posted January 22, 2016 Author Share Posted January 22, 2016 So here is what I did, although I dont think this is the right way to do it I commented lines 46, 47, 48 and it started working.... I think this may have something to do with MySQL5.7 //$this->_select = 'IFNULL(virtual.products, 0) as products'; //$this->_join = 'LEFT JOIN (SELECT id_attachment, COUNT(*) as products FROM '._DB_PREFIX_.'product_attachment GROUP BY id_attachment) virtual ON a.id_attachment = virtual.id_attachment'; //$this->_use_found_rows = false; Link to comment Share on other sites More sharing options...
scsiborg Posted March 8, 2016 Share Posted March 8, 2016 OK. The reason this is happening is because they are using the reserved keyword "virtual" as the name of derived joined table, you cant do that with later verisons of mysql. Just rename all instances of virtual to virtualx. A find and replace will help here. Also where you see "virtual ON", change that to "as virtualx ON" 3 Link to comment Share on other sites More sharing options...
David Eschmeyer Posted August 25, 2016 Share Posted August 25, 2016 more details for everyone else: /controllers/admin/AdminAttachmentsController.php change $this->_select = 'IFNULL(virtual.products, 0) as products'; $this->_join = 'LEFT JOIN (SELECT id_attachment, COUNT(*) as products FROM '._DB_PREFIX_.'product_attachment GROUP BY id_attachment) virtual ON a.id_attachment = virtual.id_attachment'; to $this->_select = 'IFNULL(virtualx.products, 0) as products'; $this->_join = 'LEFT JOIN (SELECT id_attachment, COUNT(*) as products FROM '._DB_PREFIX_.'product_attachment GROUP BY id_attachment) virtualx ON a.id_attachment = virtualx.id_attachment'; and further down 'filter_key' => 'virtual!products', to: 'filter_key' => 'virtualx!products', 2 Link to comment Share on other sites More sharing options...
Patrick Proot Posted October 25, 2016 Share Posted October 25, 2016 Thanks very much work perfectly for 1.6.5 1 Link to comment Share on other sites More sharing options...
eec Posted September 24, 2018 Share Posted September 24, 2018 Thank you very much, worked perfectly on our shop as well. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now