Jump to content

Requête SQL pour GROUP (et si possible CONNEXION)


Recommended Posts

Bonjour !

      Voici ma requête SQL pour faire apparaitre mes clients + mes adresses :

SELECT
pc.`id_customer`,
pc.`email`,
pa.`company`,
pc.`siret`,
pc.`id_gender`,
pa.`firstname`,
pa.`lastname`,
pa.`address1`,
pa.`address2`,
pa.`postcode`,
pa.`city`,
pa.`phone`,
pa.`phone_mobile`,
pc.`birthday`,
pc.`newsletter`,
pc.`active`
FROM ps_address pa
LEFT JOIN ps_customer pc ON pa.`id_customer`=pc.`id_customer`
WHERE
pa.`deleted`=0
AND pc.`email` != ''
AND pa.`id_supplier` = 0
AND pa.`id_manufacturer` = 0
GROUP BY pa.`address1`

J'aimerais y ajouter si possible mes groupes clients et "dernière connexion" :

ID de mes groupes clients : 4 - 7 - -8 - 9 - 10 - 11 - 12 - 15

Exemple de mon groupe client 4 :

SELECT
								c.`id_customer` AS `id_customer`, `id_gender`, `firstname`, `lastname`, c.`email` AS `email`, `birthday`, `date_add`, c.`active` AS `active`
			, c.*, a.id_group
			FROM `ps_customer_group` a 
			
			LEFT JOIN `ps_customer` c ON (a.`id_customer` = c.`id_customer`) 
			 WHERE 1  AND a.`id_group` = 7 AND c.`deleted` != 1 AND c.id_shop IN (1)  
			
			 ORDER BY `id_group` ASC

Avez vous une solution pour intégrer les groupes dans mon premier code SQL ? ^^

Cordialement

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More