Jump to content

Needing Help For Sql Script


Recommended Posts

hi,
i'm writing this script trying to export main data of my shop's items:

SELECT 
a.`id_product`, b.`name` AS `name`, `reference`, 
sav.`quantity` AS `quantita`, 
a.`wholesale_price` AS `costo`, 
a.`price` AS `price`, 
b.description_short,
b.description,
---- >  GROUP_CONCAT(DISTINCT(xz.name) SEPARATOR ",") as categories,
a.`id_manufacturer` AS `manufacturer`, 
a.`id_supplier` AS `supplier`, 
sa.`active` AS `active` , shop.`name` AS `shopname`, 
a.`id_shop_default`, 
image_shop.`id_image` AS `id_image`, 
sa.`price`, 0 AS `price_final`, 
a.`is_virtual`, pd.`nb_downloadable`, 
sa.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger` 
FROM `ps_product` a 
LEFT JOIN `ps_product_lang` b ON (b.`id_product` = a.`id_product` AND b.`id_lang` = 2 AND b.`id_shop` = 1) 
LEFT JOIN `ps_stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0 AND sav.id_shop = 1 AND sav.id_shop_group = 0 ) 
JOIN `ps_product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = a.id_shop_default) 
---- > LEFT JOIN `ps_category_product` xp ON (a.`id_product` = xp.`id_product`)
---- > LEFT JOIN `ps_category_lang` xz ON (xp.`id_category` = xz.`id_category`)
LEFT JOIN `ps_shop` shop ON (shop.id_shop = a.id_shop_default) 
LEFT JOIN `ps_image_shop` image_shop ON (image_shop.`id_product` = a.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = a.id_shop_default) 
LEFT JOIN `ps_image` i ON (i.`id_image` = image_shop.`id_image`) LEFT JOIN `ps_product_download` pd ON (pd.`id_product` = a.`id_product`) 
WHERE 1 AND b.`name` LIKE '%pizza%' ORDER BY a.`id_product` ASC LIMIT 0, 50

Well... without the lines with the "---- >" all works well (the "---- > " is used only to tell you which ones, of course...)
Adding that 3 lines i can read also the CATEGORIE LIST, but ONLY FOR THE FIRST PRODUCT.
WHY?

2nd. question: how to exctract image url instead of image id, please?

Thank you all

Edited by galleriaaurea (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...