How to insert data into specific columns of a table in MySQL?

In MySQL, you can use the INSERT statement to add new data to specific columns in a table. The syntax is as follows:

INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);

For example, if there is a table named “students” with columns “id,” “name,” and “age,” you can use the following statement to add data to specific columns of this table:

INSERT INTO students (name, age) VALUES ('Alice', 20);

This will add a new record to the “students” table, containing data only in the “name” and “age” columns, with the other columns using default values or NULL.

广告
Closing in 10 seconds
bannerAds