select c.customer_id,c.bill_customer_id, c.customer_name, c.short_name, c.online_reseller, c.distributor, ct.customer_type,
cc.`name` as 'customer_category', cg.`name` as 'customer_group', c.tax_reg_no, u.salesman_code, c.store_size, c.address_line1,
c.address_line2,c.address_line3,c.address_line4, co.country_name, st.state_name, ci.city_name, c.postal_code, c.attn,c.tel,c.fax,c.email,
c.currency_code,c.credit_limit, pt.`name` as 'payment_terms', cp.customer_code as "billing_customer_code", cp.customer_name as "Billing Customer Name",
gst.`code` as 'gst_code', ca.gl_code as 'gl_code', c.note, c.`status`
from 0p4_customer c
left join 0p4_customer_type ct on ct.customer_type_id=c.customer_type_id
left join 0p4_customer_category cc on cc.id=c.customer_category_id
left join 0p4_customer_group cg on cg.customer_group_id=c.customer_group_id
left join 0p4_user u on u.id = c.sale_person_id
left join 0p4_country co on co.id= c.country_id
left join 0p4_state st on st.id=c.state_id
left join 0p4_city ci on ci.id=c.city_id
left join 0p4_payment_terms pt on pt.payment_terms_id=c.customer_term_id
left join 0p4_customer cp on cp.customer_id=c.bill_customer_id
left join 0p4_gst gst on gst.gst_id=c.gst_id
left join 0p4_chart_account ca on ca.chart_account_id=c.chart_account_id
where c.isDeleted!=1
limit 20;

select cd.id,c.customer_id,c.customer_code,c.customer_name,cd.address_1, cd.address_2, cd.address_3, cd.address_4, co.country_name,
s.state_name, ct.city_name, cd.area, cd.postal_code,cd.attn, cd.tel, cd.fax, cd.email
from 0p4_customer_delivery_address cd
left join 0p4_customer c on c.customer_id=cd.customer_id
left join 0p4_country co on co.id=c.country_id
left join 0p4_state s on s.id=cd.state_id
left join 0p4_city ct on ct.id= cd.city_id
where c.isDeleted != 1;

select c.customer_id,c.customer_code,c.customer_name, cc.contact_person,cc.title,cc.department, cc.tel, cc.fax, cc.email
from 0p4_customer_contact cc
left join 0p4_customer c on c.customer_id=cc.customer_id
where c.isDeleted != 1
and (cc.contact_person!="" or cc.title!="" or cc.department!="" or cc.tel!="" or cc.fax!="" or cc.email!="" );
