List:General Discussion« Previous MessageNext Message »
From:mickalo Date:August 8 2001 12:12am
Subject:Re: Zerofill Auto_Increment
View as plain text  
Thanks Paul,

That works fine. :) 

>>On Tue, 7 Aug 2001 16:12:16 -0500, Paul DuBois <paul@stripped>   wrote:

>>>Hi All,
>>>
>>>Not sure if this is a bug or just a standard behavior of a auto_increment
>>>zerofill column.
>>>
>>>I have a column in a MySQL database table assigned as such:
>>>
>>>memid int(8) auto_increment zerofill primary key,
>>>
>>>now when the a new row is inserted in fills the column with the 
>>>appropriate 0's,
>>>but when I do a 'SELECT LAST_INSERT_ID()', after the insert, I get the last
>>>insert number, without the zeros, IE... Last inserted id value = 
>>>'00000012' but
>>>the return value is '12' and if I do a SELECT * FROM table_name WHERE memid =
>>>'12'; or SELECT * FROM table_name WHERE memid = '00000012';
>>>
>>>I get the same results, whether I use '12' or '00000012'
>>>
>>>Is this suppose to do that?? Just curious :)
>>
>>
>>LAST_INSERT_ID() returns a function value, not a table column value.
>>To get the result you want, you could use LPAD(LAST_INSERT_ID(),8,'0').

Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel: 1(225)686-2002
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Thread
Zerofill Auto_Incrementmickalo7 Aug
  • Re: Zerofill Auto_IncrementPaul DuBois7 Aug
    • Re: Zerofill Auto_Incrementmickalo8 Aug