Here I have a mysql table like this:
create table abc (
name varchar(20) not null,
value int not null default 20
)
and in the php page, I wanna use a uniform sql for all insert like this:
insert into abc values('first name', '30')
but sometimes, there maybe someone dont input a value and the insert sql will be like
insert into abc values('a name', '')
and why can’t it work? The mysql says Incorrect integer value: '' for column... and
I want it give the default value. How can I do that?
You can’t insert a not-integer-value into your field if you have declared it as an integer with
NOT NULL.1) Either control the value via your code if you want to use the same
INSERTstatement in both cases…2) … or have two different
INSERTs for your default values: