Inserting rows into MySql can be done in a couple of ways. You can use the INSERT…VALUES and INSERT…SET commands. The first option INSERT…VALUES syntax is:


The second option INSERT…SET syntax alternative requires that you specify each field name with its counterpart in the same format as update queries.

If you are inserting new values in every field for a table then the first option is the most simple. You can always design your system such that it will accept NULL values. If however you only want to insert values into particular fields within a table you could use the second option.

What ID was that field given?

Often after inserting a row you want to know what value that row was given. MySql will return the last insert row with the following php command

Further Information on INSERT

Last Updated:
Posted in MySQL

Comments 0

Write a Reply or Comment

We will not publish your email.*