close

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' );

arrow
arrow
    全站熱搜

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