Aim:

Insert a new data in a table which some columns have default value.

 

Table set :

[ id ] [ auto_increament ]

[name] [ varchard(30) ]

[concern_prefer] [ varchard(30) ] [ Default : simple ]

[concern_show]  [ varchard(30) ] [ Default : 20 ]

[ time ] [ DATETIME ]

 

Wrong Solution:

INSERT INTO testing VALUES ( '' , 'Louis' , DEFAULT , DEFAULT , NOW() );

 

Problem:

Mysql can't use DEFAULT to assign value for data

 

Right Solution:

INSERT INTO testing ( id, name ) VALUES ( '' , 'Louis' );

guardian801202 發表在 痞客邦 PIXNET 留言(0) 人氣()