Data can be inserted in to an existing database table with an INSERT INTO query that first specified the table name. The SQL VALUES keyword then specifies the actual data to be inserted as comma-separated list with in parentheses, like this :
INSERT INTO table-name VALUES(value, value);Each INSERT INTO query inserts just one row into the database table. A data value must be specified for each column – and in the corresponding order. The data to inserted must also match the data type in each column’s definition or an error will be generated.The NULL keyword can be specified to leave a field empty if that column’s definition allow NULLvalues.
The INSERT INTO query can be improved by adding a “column list” to explicitly specify the table column into which each value should be inserted. This changes the syntax of the INSERT INTO query like this :
INSERT INTO table-name(column-name,column-name,column-name) VALUES(value,value,value);
When the INSERT INTO query contains a column list the MySQL Server matches each value to the specified column in the order in which they are listed – the value listed will be matched to the column listed first, the value listed second will be matched to the column listed second and so on. The number listed values must match the number of listed columns, but the columns need to be listed in the order in which they appear in the database table.
Any text values to be inserted into a database must be enclosed with in quotation marks.Ex :
CREATE TABLE IF NOT EXISTS tblemployees( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), designation VARCHAR(100), salary decimal(6,2) ); // Query for data insertion INSERT INTO tblemployees(name,designation,salary) VALUES("Anuj kumar","software Developer","60000.00"), ("John Doe","Accountant","80500.25"), ("Garima","HR Executive","40134.65");