Jump to content

Edit History

EvaF

EvaF

something like that (customize fields, id_lang and output file)

 

SELECT "id_customer", "id_gender", "id_lang", "company", "firstname", "lastname", "email", "active", "is_guest",
"id_country","country", "acompany", "alastname", "afirstname" ,
"address1", "address2", "postcode", "city", "phone", "phone_mobile", "vat_number", "aactive", "adeleted" 
union all

select * from(
   
  SELECT c.`id_customer`, c.`id_gender`, c.`id_lang`, if(c.`company` is null,"",c.`company`) , c.`firstname`, c.lastname, c.`email`, c.`active`, c.`is_guest`,
a.`id_country`,cl.name, if(a.`company` is null,"",a.`company`), a.`lastname` as alastname, a.`firstname` as afirstname,
  `address1`, if(a.`address2` is null,"",a.`address2`) , `postcode`, `city`, `phone`, `phone_mobile`, `vat_number`, a.`active` as aactive, a.`deleted` as adeleted 

  FROM `ps_customer` c 

  join `ps_address` a on c.id_customer = a.id_customer
  join ps_country_lang cl on cl.id_country = a.id_country and cl.id_lang= 1
  WHERE a.deleted=0 and a.active=1 and c.deleted = 0 and c.active=1
  order by cl.name, c.lastname,c.firstname
) as cust

INTO OUTFILE '/tmp/customers.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
EvaF

EvaF

something like that (customize fields, id_lang and output file)

 

SELECT "id_customer", "id_gender", "id_lang", "company", "firstname", "lastname", "email", "active", "is_guest",
"id_country","country", "acompany", "alastname", "afirstname" , "address1", "address2", "postcode", "city", "phone", "phone_mobile", "vat_number", "aactive", "adeleted" 
union all

select * from(
   
  SELECT c.`id_customer`, c.`id_gender`, c.`id_lang`, if(c.`company` is null,"",c.`company`) , c.`firstname`, c.lastname, c.`email`, c.`active`, c.`is_guest`,
a.`id_country`,cl.name, if(a.`company` is null,"",a.`company`), a.`lastname` as alastname, a.`firstname` as afirstname, `address1`, if(a.`address2` is null,"",a.`address2`) , `postcode`, `city`, `phone`, `phone_mobile`, `vat_number`, a.`active` as aactive, a.`deleted` as adeleted 

  FROM `ps_customer` c 

  join `ps_address` a on c.id_customer = a.id_customer
  join ps_country_lang cl on cl.id_country = a.id_country and cl.id_lang= 1
  WHERE a.deleted=0 and a.active=1 and c.deleted = 0 and c.active=1
  order by cl.name, c.lastname,c.firstname
) as cust

INTO OUTFILE '/tmp/customers.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
×
×
  • Create New...