SELECT distinct order_id orders_id, user_id customers_id, trim(concat(f_name,' ',l_name))
  customers_name,firma_name  customers_company 
, street  customers_street_address, '' customers_suburb, 
 city customers_city,  zip customers_postcode, state customers_state,
  b.name customers_country, 
 phone customers_telephone, email customers_email_address, 
 0 customers_address_format_id,  
trim(concat(d_f_name,' ',d_l_name)) delivery_name,
 d_firma_name delivery_company, 
 d_street delivery_street_address,  '' delivery_suburb,d_city  delivery_city,  
d_zip delivery_postcode,  d_state delivery_state,c.name   delivery_country, 
 0 delivery_address_format_id, trim(concat(f_name,' ',l_name)) billing_name, 
 firma_name billing_company,
  street billing_street_address, ''  billing_suburb, city  billing_city, 
zip  billing_postcode,state  billing_state, b.name  billing_country, 
0 billing_address_format_id, payment_method_id payment_method, 
 ''cc_type,  ''cc_owner, '' cc_number,  ''cc_expires, 
 order_m_date last_modified,
 order_date date_purchased, order_status orders_status, 
 order_date orders_date_finished, currency_code currency, 
 currency_exchange currency_value 

FROM <@PREFIX>jshopping_orders a left join
  <@PREFIX>jshopping_languages b on a.country = b.id
left join
  <@PREFIX>jshopping_languages c on a.d_country = c.id

 

