Posted By

gcman105 on 05/20/10


Tagged

mysql textmate WAFapp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

gcman105


MySQL customers invoices


 / Published in: MySQL
 

  1. SELECT DISTINCT
  2. invoice.invoice_id,
  3. invoice.invoice_total,
  4. invoice.invoice_paid,
  5. invoice.invoice_tax,
  6. invoice.ts_printed,
  7. invoice.ts_add,
  8. ROUND(invoice.invoice_total-invoice.invoice_paid, 2) AS to_pay,
  9. orders.customer_ref,
  10. delivery_note.delivery_note_id
  11. FROM
  12. invoice
  13. INNER JOIN order_items ON order_items.invoice_ref = invoice.invoice_id
  14. INNER JOIN orders ON order_items.order_ref = orders.order_id
  15. INNER JOIN delivery_note ON order_items.delivery_note_ref = delivery_note.delivery_note_id
  16. WHERE
  17. orders.customer_ref = '$cid'
  18. AND
  19. invoice.invoice_paid < invoice.invoice_total
  20. ORDER BY
  21. invoice.invoice_id DESC

Report this snippet  

You need to login to post a comment.