In MySQL, the INSERT INTO statement is used to add new rows of data into a table. It allows you to specify the values to be inserted into specific columns of the table. Here's the basic syntax of the INSERT INTO statement:
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Where:
Here's an example:
INSERT INTO employees (first_name, last_name, department, salary)
VALUES ('John', 'Doe', 'Sales', 50000);
This query will insert a new row into the employees table with values 'John' for the first_name column, 'Doe' for the last_name column, 'Sales' for the department column, and 50000 for the salary column.
You can also insert multiple rows into a table with a single INSERT INTO statement by specifying multiple sets of values separated by commas:
INSERT INTO employees (first_name, last_name, department, salary)
VALUES ('Jane', 'Smith', 'Marketing', 60000),
('Bob', 'Johnson', 'IT', 70000),
('Emily', 'Brown', 'Finance', 55000);
This query will insert three new rows into the employees table with the specified values.
The INSERT INTO statement is a fundamental part of SQL and is used extensively for adding data to database tables.