In message <[EMAIL PROTECTED]>, Joseph <[EMAIL PROTECTED]
o.uk> writes
>--- In [email protected], "Brian Boothe" <[EMAIL PROTECTED]> wrote:
>I have a mysql database table setup already but I need to go back and 
>enter
>in a 4 digit Company Code to each of my records how can I do this
>automatically that starts at the First record with 0000
>
>And automatically Increments and inserts into each of the rest of the
>records: ,, thanks for all your help
>
>-------------------------------------------------------------
>Hi Brian
>
>I am assuming that the company code field doesn't currently exist. if 
>it doesn't, I would recommend that you export your table using 
>phpmyadmin (or some such), then delete the data and reinsert it using 
>phpmyadmin.
>
>But before you do, you can change/insert the company code field to 
>auto increment using the required 4 digits starting at 0000. Now when 
>you import your data the company code field should be filled in 
>automatically, starting at 0000, 0001, etc. 
>
>Hope that helps.
>
>Joseph

You don't need to export and import - just add an autoinc field, and it
will magically contain all the values (without the leading zeroes) -
that is, it will contain 1,2,3, not 0001, 0002, 0003, etc.

You can then amend the field if you really need the zeros - but I would
try to avoid them, as it adds complications, and would just "add them to
any display" when you put them on screen.

-- 
Pete Clark

Sunny Andalucia
http://hotcosta.com/Andalucia.Spain

Reply via email to