mysql can't insert record with unsigned primary key being zero -


i trying insert 1 record dim_channel table 0 primary key (unsigned int).

mysql command:

insert dim_channel  set channel_id=0,name='other',parent_channel_id=0,parent_channel_name='other'; 

results:

select * dim_channel; +------------+-------+-------------------+---------------------+ | channel_id | name  | parent_channel_id | parent_channel_name | +------------+-------+-------------------+---------------------+ |          1 | other |                 0 | other               | +------------+-------+-------------------+---------------------+ 

please note channel_id got value 1, not 0 expected.

any 1 knows why happens.

by way, can update record as: update dim_channel set channel_id=0 channel_id=1;

just want know why can't insert record channel_id=0 @ first place.

thanks lot.

====== mysql command test ====

-- create table

create table `dim_channel` (   `channel_id` int(10) unsigned not null auto_increment,   `name` char(80) default null,   `parent_channel_id` int(10) unsigned not null default '0',   `parent_channel_name` varchar(80) default null,   primary key (`channel_id`) ) engine=myisam default charset=latin1 

-- insert record

insert dim_channel set channel_id=0,name='other',parent_channel_id=0,parent_channel_name='other'; 

-- see result

select * dim_channel; 

it because have auto-increment primary key on field. if assign null or 0 value on insert explicitly give next number in sequence table.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -