MySQL ERROR 1048 (23000) Column ‘x’ cannot be null

When you don’t put any value in some column of the table then you might seen that MySQL throws ERROR 1048 (23000) Column ‘x’ cannot be null. Here we will see why we get error ERROR 1048 (23000) Column ‘x’ can not be null.

MySQL throws ERROR 1048 (23000) Column ‘x’ cannot be null when we try to insert the empty value or null value or don’t insert any value in the column which is marked with not null or Primary key constraints.

mysql-select-query

Here id is the primary key so it cannot be null. If we try to insert a null value in the id column then MySQL will throw ERROR 1048 (23000): Column ‘id’ cannot be null.

insert into dept values (null,'security');
ERROR 1048 (23000): Column 'id' cannot be null
Scroll to Top