MySQL Forums
Forum List  »  InnoDB

include line number depending on field
Posted by: pascual bayo
Date: September 25, 2012 07:48AM

Hello,

I've got a table in my database where I store the order lines. I am using a sh script to export that table to a csv.
What I need is to show the line number in its order, so if it outputs the first order, lines would be:
1,product1
2,product2
3,product3

for the second order, lines would begin with 1, so I can see for every order, the numbered lines.

Is there any way to achieve this, something like incrementing a variable and reseting it to 0 when a new order_id is found?

I've achieved creating a variable and incrementing it on every iteration, but I don't know how to know the field.

Thanks you!



Edited 1 time(s). Last edit at 09/25/2012 08:03AM by pascual bayo.

Options: ReplyQuote


Subject
Views
Written By
Posted
include line number depending on field
1377
September 25, 2012 07:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.