MySQL sequential number problem.

I've set up a database in MySQL to track Change Orders (Field #1) for engineered products by Serial Number (Field #2).  Each product is custom designed, so more that one Change Order will likely be issued for each Serial Number.  How can I get MySQL to retrieve the next sequential Change Order number for a given Serial Number when I input the Serial Number?  It seems like I may have to do some type of scripting.  But if there is an easier way, I'm all for it.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What determines the next Change Order number? Do you just want to know the last one that's in the table for that serial number?

select max(Change_Order)
from your_table
where Serial_Number = your_serial_number

if you don't get a result back then that serial number wasn't found.

Does that answer your question? If not, let me know in a little more detail what you need.


You may have to do this way

select max(Change_Order) +1
from   your_table
where Serial_Number = your_serial_number

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jamesclancyAuthor Commented:
Thank you for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.