Professional Web Applications Themes

adding record w ID=0 - MySQL

I have an already existing table created w auto-increment (starting : 1) I need to add a record w ID=0 manually... I tried to do it w phpmyadmin... but I always get a new record w the last increment value +1 never the 0... how can I do it manually ? thanks for your help .. joss...

  1. #1

    Default adding record w ID=0

    I have an already existing table created w auto-increment (starting : 1)
    I need to add a record w ID=0 manually...
    I tried to do it w phpmyadmin... but I always get a new record w the
    last increment value +1 never the 0...
    how can I do it manually ?

    thanks for your help ..

    joss

    Josselin Guest

  2. #2

    Default Re: adding record w ID=0

    On Jun 20, 6:03 am, Josselin <fr> wrote: 

    You can't.

    You can alter the table...

    ALTER TABLE `my_table` CHANGE `id` `id` TINYINT( 4 ) NOT NULL

    ....and then insert your 0 value...

    INSERT INTO `my_table` (id) VALUES (0)

    ....but when you revert the structure...

    ALTER TABLE `id` CHANGE `id` `id` TINYINT( 4 ) NOT NULL
    AUTO_INCREMENT

    ....the table will renumber itself from 1!

    strawberry Guest

  3. #3

    Default Re: adding record w ID=0

    On 2007-06-20 14:48:07 +0200, strawberry <com> said:
     
    >
    > You can't.
    >
    > You can alter the table...
    >
    > ALTER TABLE `my_table` CHANGE `id` `id` TINYINT( 4 ) NOT NULL
    >
    > ...and then insert your 0 value...
    >
    > INSERT INTO `my_table` (id) VALUES (0)
    >
    > ...but when you revert the structure...
    >
    > ALTER TABLE `id` CHANGE `id` `id` TINYINT( 4 ) NOT NULL
    > AUTO_INCREMENT
    >
    > ...the table will renumber itself from 1![/ref]

    OK thanks.. maybe creating a new table with increment starting at 0
    then importaing all data and renaming the table ...

    Josselin Guest

  4. #4

    Default Re: adding record w ID=0

    On Jun 22, 6:43 am, Josselin <fr> wrote: [/ref]
    > [/ref]
    > [/ref]








    >
    > OK thanks.. maybe creating a new table with increment starting at 0
    > then importaing all data and renaming the table ...[/ref]

    Or just add a 'my_id' column with a value 1 less than the id coulmn -
    or just SELECT id -1 FROM my_table

    Why do you need to start at 0 anyway?

    strawberry Guest

Similar Threads

  1. Adding record
    By Jayson in forum FileMaker
    Replies: 1
    Last Post: October 30th, 09:05 AM
  2. Adding a new record
    By Van in forum Microsoft Access
    Replies: 2
    Last Post: August 19th, 09:20 PM
  3. Stop adding record in subform after record count = 1
    By Charlie in forum Microsoft Access
    Replies: 0
    Last Post: July 31st, 10:42 AM
  4. Adding a new record when the record source is a query.
    By Andy in forum Microsoft Access
    Replies: 0
    Last Post: July 29th, 01:41 PM
  5. Adding record to MDB
    By Leif Hauge in forum ASP Database
    Replies: 2
    Last Post: July 7th, 10:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139