ERROR: Could not able to execute INSERT INTO saveanswer (answer) VALUES ('d'). Field 'sanswer' doesn't have a default value
Asked
Active
Viewed 1,115 times
-2

Cœur
- 37,241
- 25
- 195
- 267

Anuruddh Mishra
- 11
- 4
-
give default value null to sanswer column. – Sep 16 '16 at 10:58
-
Providing the value for `sanswer` will solve your error. It is declared `not null` (it is probably your primary key) and not autoincrement, so you have to set the value (or use autoincrement or a default value). – Solarflare Sep 16 '16 at 10:58
-
Possible duplicate of [mysql error 1364 Field doesn't have a default values](http://stackoverflow.com/questions/15438840/mysql-error-1364-field-doesnt-have-a-default-values) – Alex Andrei Sep 16 '16 at 11:02
1 Answers
0
One option will be to specify a value for that field in the query like this:
INSERT INTO saveanswer (answer, sanswer) VALUES ('d', 'something here')
Other solution will be to alter your table to set a default value for that field (null or something else) like this:
ALTER TABLE saveanswer ALTER COLUMN sanswer SET DEFAULT null;

Daniel Dudas
- 2,972
- 3
- 27
- 39