SELECT i.id, i.invoice_number, c.company_name as customer_name, i.invoice_date, i.due_date,
   i.total_amount, i.status, i.payment_status, i.created_at
   FROM invoices i
   LEFT JOIN customers c ON i.customer_id = c.id