I want to insert a row into my table X which is made of columns A, B and C.
How can I do an insert into X (A, B) values (NULL, 'hello'); without getting an error? I get an error when I don’t include column C.
I’m omitting the third column in the SQL query and A is an id auto increment.
Is there a way to only insert the first two columns and later do an update for the third column?
I’m not sure the error you are getting, so this is half-guess.
Most likely, your
Ccolumn is set toNOT NULLand has noDEFAULTvalue. Which means it needs to be populated at time of insert. If you want to skip setting it’s value on initial insert you’ll need to either give a default value for the column, or allow it to be nullable.Also, if you want column A to populate it’s auto-inc value, you’ll need to leave it out of the insert, instead of trying to set the value to NULL