Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL skip a column name when inserting values

Tags:

mysql

I have a table in which the first column is auto_increment. I want to insert data into the table, but skip the first column as it is updated automatically when a new row is begun. so:

INSERT INTO table VALUES (NULL,"lady","gaga","rulz");

But NULL cannot be inserted into a column as I specified earlier. What do I need to replace NULL with so that the column doesn't get anything inserted into it?

like image 964
Gal Avatar asked Jan 23 '23 23:01

Gal


1 Answers

Just make sure you specify the respective column names

INSERT INTO table (col1, col2, col3) VALUES ("lady","gaga","rulz");

You don't even need to fill all columns (if they are not required), Ie.

INSERT INTO table (col2) VALUES ("gaga");
like image 59
Carlos Lima Avatar answered Jan 31 '23 06:01

Carlos Lima