You can set the INT column to value NULL.The column INT type a nullable column. The syntax is as follows:
INSERT INTO yourTableName(yourIntColumnName) values(NULL);
To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> create table nullableIntDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Price int, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.80 sec)
Insert the record as NULL for a int column ‘Price’. The query is as follows:
mysql> insert into nullableIntDemo(Price) values(NULL); Query OK, 1 row affected (0.11 sec) mysql> insert into nullableIntDemo(Price) values(100); Query OK, 1 row affected (0.15 sec) mysql> insert into nullableIntDemo(Price) values(200); Query OK, 1 row affected (0.12 sec) mysql> insert into nullableIntDemo(Price) values(NULL); Query OK, 1 row affected (0.13 sec) mysql> insert into nullableIntDemo(Price) values(NULL); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from nullableIntDemo;
The following is the output:
+----+-------+ | Id | Price | +----+-------+ | 1 | NULL | | 2 | 100 | | 3 | 200 | | 4 | NULL | | 5 | NULL | +----+-------+ 5 rows in set (0.00 sec)
Look at the above sample output, in MySQL int column is a nullable.