Page 1 of 1

Counter Running off Databse

Posted: Sat Oct 16, 2004 3:57 am
by bobbyaa
Any ideas on how I can incorporate an object into all of the pages that displays the next available number from a database? The idea is that the end user needs to be able to see this number to give it out prior to typing the information into the form. Ideally, I would prefer that it automatically update when someone else changes it. Thanks in advance.

Posted: Sat Oct 16, 2004 4:56 am
by timvw
SELECT MAX(foo) + 1 AS next FROM bar;

But i prefer to use autoincrement with mysql. I presume most rdbms will have a similar option

Posted: Mon Oct 18, 2004 5:32 am
by Christopher
Most databases have sequences. You can emulate them in MySQL with a table with a single record in a single INT column.