MySQL Forums
Forum List  »  Newbie

Update a table with an incremental number for each occurrence of a value
Posted by: John Galvin
Date: December 21, 2005 07:11AM

Hi There,

Ideally I am looking for a way to append a numerical value to each record where it has found a recurrence of a value, e.g. where the data captured is firstname, lastname, email, item and price:

John, Galvin, jgalvin@anywhere.com, Camera, 200.00
John, Galvin, jgalvin@anywhere.com, Tripod, 34.99
John, Galvin, jgalvin@anywhere.com, Memory Stick, 65.00
Tony, Galvin, tgalvin@anywhere.com, Phone, 150.00
Tony, Galvin, tgalvin@anywhere.com, Phone Case, 25.00
Bill, Galvin, bgalvin@anywhere.com, MP3 Player, 70.00

The field which we're using to count on is email address, and ideally the result I would like is to append a numerical value which corresponds to the number of distinct orders for that email address:

John, Galvin, jgalvin@anywhere.com, Camera, 200.00, 1
John, Galvin, jgalvin@anywhere.com, Tripod, 34.99, 2
John, Galvin, jgalvin@anywhere.com, Memory Stick, 65.00, 3
Tony, Galvin, tgalvin@anywhere.com, Phone, 150.00, 1
Tony, Galvin, tgalvin@anywhere.com, Phone Case, 25.00, 2
Bill, Galvin, bgalvin@anywhere.com, MP3 Player, 70.00, 1

Can anybody suggest a way of achieving this?

Thanks

John

Options: ReplyQuote


Subject
Written By
Posted
Update a table with an incremental number for each occurrence of a value
December 21, 2005 07:11AM


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.