• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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.
0
jamesclancy
Asked:
jamesclancy
1 Solution
 
david_levineCommented:
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.

David
0
 
sgantaCommented:
Hi

You may have to do this way

select max(Change_Order) +1
from   your_table
where Serial_Number = your_serial_number
0
 
jamesclancyAuthor Commented:
Thank you for your help.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now