Hi all.. how can I make code, based on year, month and increment number? the format is : Code + year+ month + number for example, for document, it will have code : DOC20080601 DOC20080602 DOC20080603 . . DOC20080699
I'm confuse because I don't know how to go to the last record in mysql. If use sqlserver, I can go to last record, get the number, and auto increment it. But, how can I make in php-mysql?
Thank you so much
siMKin
9:38 am on Jun 28, 2008 (gmt 0)
you could, for example, do an Order By Desc in combination with a Limit 0,1 to get the last record. or use MAX to get the highest value.
But you should ask yourself what happens if there are more then 99 documents in 1 month......
doxtor
12:22 pm on Jun 28, 2008 (gmt 0)
can you explain clearly for "do an Order By Desc in combination with a Limit 0,1 to get the last record..." Still confuse with 'combination with a limit' :) Yes, i know there is a limitation, that the document max is 99. That's just example. thank you
siMKin
2:28 pm on Jun 29, 2008 (gmt 0)
SELECT * FROM table ORDER BY id DESC LIMIT 0,1 or SELECT MAX(id) FROM table