Insert

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:

Example:

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

About CDB 360 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.