I'm looking to export a csv file from the data from my 2 tables 'Order_Headers' and 'Order_Lines' that will look like this
ORDH 10061 0 07/07/14 Bob Davies 32 Somewhere street etc
ORDL 10061 1 Product one Price etc
ORDL 10061 2 Product one Price etc
ORDL 10061 3 Product one Price etc
ORDH 10062 0 07/07/14 Peter Williams 45 Somewhere else road etc
ORDL 10062 1 Product one Price etc
ORDL 10062 2 Product one Price etc
ORDL 10062 3 Product one Price etc
ORDL 10062 4 Product one Price etc
The part I'm stuck with is the 3rd column, how do I count the number of items with each order line and enter the number into my 3rd column in MySQL database table?
As you can see with each new order the count needs to go back to zero as I'm only looking to count and record the number of order lines per invoice number.