1

I want to insert one value into a row. This row has multiple values. When I try to insert show error row-1 does not have default value.

$NoName = "Record_name"; $no = "20"; // I want to INSERT this no in row $sql4 = "INSERT INTO record (date, month, year, $NoName) VALUES ('12-12-2016','12','2017', '$no')"; $result4 = mysqli_query($mysqli,$sql4) or die(mysqli_error($mysqli)); 

There is some more other rows like no 1, no 2,no 3 i just want to insert no 1 value in new row other values will be empty.

10
  • 2
    If a column does not have a default value set in the schema, you must set a value for that column on an INSERT Commented Jan 5, 2017 at 11:43
  • do you want to update or insert? since in your comment you stated update Commented Jan 5, 2017 at 11:45
  • but i want to insert only one. when user record come i will update it by update cmd Commented Jan 5, 2017 at 11:45
  • i select all record by date when date change insert new record in new row. when new record come at same date it will update in same date Commented Jan 5, 2017 at 11:46
  • 1
    Why do you SHOUT in your questions title? Commented Jan 5, 2017 at 11:48

1 Answer 1

1

You can add a default value to that column:

ALTER TABLE record ADD DEFAULT '0000-00-00' FOR date 

This is from :

How to set a default value for an existing column

Note that you should use a valid default value.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.