I am working with Prestashop 1.6.0.6, it appears to have a bug where randomly the virtual product file disappears and is no longer available for download and needs to be re-uploaded. So I am trying to write a query that will display all active products that have virtual products and whether that virtual product is active. In some instances since I have uploaded a second time the virtual product is active can be 0 or 1, by summing I can get the final active status.
I have found all the tables I need to write the query;
ps_product_lang->id_product
ps_product_lang->name
ps_product->id_product
ps_product->is_virtual
ps_product->active
ps_product_download->id_product
ps_product_download->display_filename
ps_product_download->filename
ps_product_download->active
I have limited mySQL query knowledge so normally write the query in MS Accesss then use the SQL view and copy to mySQL and normally it works with a little tweaking. In this instance I am using grouping, first and summing (is virtual product active) and can't get the query to work. I keep getting syntax errors. This is the query I am using;
SELECT ps_product_lang.id_product,
First(ps_product_lang.name) AS FirstOfname,
First(ps_product.is_virtual) AS FirstOfis_virtual,
First(ps_product.active) AS FirstOfactive,
First(ps_product_download.display_filename) AS FirstOfdisplay_filename,
First(ps_product_download.filename) AS FirstOffilename,
Sum(ps_product_download.active) AS SumOfactive
FROM (ps_product
RIGHT JOIN ps_product_lang ON ps_product.id_product = ps_product_lang.id_product)
LEFT JOIN ps_product_download ON ps_product.id_product = ps_product_download.id_product
GROUP BY ps_product_lang.id_product
HAVING (((First(ps_product.is_virtual))=1) AND ((First(ps_product.active))=1));
Any help to get the query working would be appreciated.
FIRST()in mysql. You also should remove the paranthesis fromFROM (ps_product