Page 200 - CITS - Computer Software Application -TT
P. 200

COMPUTER SOFTWARE APPLICATION - CITS





           The INSERT INTO statement is used to add new records to a MySQL table:
           INSERT INTO table_name (column1, column2, column3,...)
           VALUES (value1, value2, value3,...)

           To learn more about SQL, please visit our SQL tutorial.
           In  the  previous  chapter  we  created  an  empty  table  named  “MyGuests”  with  five  columns:  “id”,  “firstname”,
           “lastname”, “email” and “reg_date”. Now, let us fill the table with data.
           Note: If a column is AUTO_INCREMENT (like the “id” column) or TIMESTAMP with default update of current_
           timesamp (like the “reg_date” column), it is no need to be specified in the SQL query; MySQL will automatically
           add the value.

           The following examples add a new record to the “MyGuests” table:
           Example (MySQLi Object-oriented):









































           Select Data From a MySQL Database
           The SELECT statement is used to select data from one or more tables:





           or we can use the * character to select ALL columns from a table:




           Select Data With MySQLi

           The following example selects the id, firstname and lastname columns from the MyGuests table and displays it
           on the page:




                                                           187

                             CITS : IT&ITES - Computer  Software Application - Lesson 47 - 62
   195   196   197   198   199   200   201   202   203   204   205