Jump to content

Selection depuis la base de données


bhbcom

Recommended Posts

Bonjour,

voici un exemple :

$sql = 'SELECT od.idproduct, pl.name, SUM(od.`product_quantity`) AS total
				FROM `'._DB_PREFIX_.'order_detail` od
				LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
                                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = od.`product_id`
				WHERE od.`product_id` = '.(int)$id_product.'
					'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
					AND o.`valid` = 1
                                        AND pl.`id_lang` = '.$idlang.'
					AND (o.`invoice_date` >= \''.$date1.'\')
					AND (o.`invoice_date` < \''.$date2.'\'))';

A vérifier car de tête et à personnaliser

  • Like 1
Link to comment
Share on other sites

Bonjour,

voici un exemple :

$sql = 'SELECT od.idproduct, pl.name, SUM(od.`product_quantity`) AS total
				FROM `'._DB_PREFIX_.'order_detail` od
				LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order`
                                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = od.`product_id`
				WHERE od.`product_id` = '.(int)$id_product.'
					'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
					AND o.`valid` = 1
                                        AND pl.`id_lang` = '.$idlang.'
					AND (o.`invoice_date` >= \''.$date1.'\')
					AND (o.`invoice_date` < \''.$date2.'\'))';

A vérifier car de tête et à personnaliser

 

Merci!

 

Çà marche bien.

SELECT product_id, product_name, SUM(product_quantity) AS total
	FROM kn_order_detail
	LEFT JOIN kn_orders ON kn_orders.id_order = kn_order_detail.id_order
	WHERE kn_orders.valid = 1
		AND (kn_orders.invoice_date >= '2014-01-01')
		AND (kn_orders.invoice_date < '2015-01-01')
	GROUP BY product_id;

Maintenant j'ai besoin de trouver le nombre total des ventes pour chaque couleur.

 

Noir | Total ventes

Blanc | Total ventes

Rouge | Total ventes

 

Je sais que les tables pour déclinaison c'est kn_product_attribute et kn_product_attribute_combination mais je ne peux pas trouver les couleur la-bas..

Edited by bhbcom (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...