MySQL Insert Into


- Advertisement -

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 :

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 :

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 :

- Advertisement -

Leave A Reply

Your email address will not be published.