Page 93 - PowerPoint Presentation
P. 93

CAVITE STATE UNIVERSITY
                               T3 CAMPUS
                               Department of Information Technology          DCIT 55 – Advance Database System

               MySQL INSERT INTO
               The INSERT INTO statement is used to insert new records in a table. There are two ways
               using INSERT INTO statement for inserting rows. Below is the syntax for insert command.

                   INSERT INTO table_name(column1, column2, column3, ..) VALUES (value1, value2,
                                                        value3,);

               If you are adding values for all the columns of the table, you do not need to specify the column
               names in the SQL query. However, make sure the order of the values is in the same order as
               the columns in the table. The INSERT INTO syntax would be as follows:
                              INSERT INTO table_name VALUES (value1, value2, value3, ..);

               Example: If you want to insert data in all columns, then INSERT INTO statement would be
               shown below:
                              INSERT INTO cus_tbl VALUES (101, ‘Christian’, ‘Langit’);

               Example:  If  you  want  to  insert  data  only  in  specified  columns,  then  the  INSERT  INTO
               statement would be shown below:

                INSERT INTO cus_tbl (cus_id, cus_fname, cus_lname) VALUES (101, ‘Christian’, ‘Langit’);

               MySQL INSERT INTO (to insert multiple records)
               We can  also  insert  multiple  (more than one)  records  into  a table by using  INSERT  INTO
               statement. Below is the syntax for multiple insert command.

                INSERT INTO table_name (column1, column2, column3) VALUES (value1, value2, value3),
                                    (value1, value2, value3), (value1, value2, value3);

               Example: If you want to insert multiple records into a table, the INSERT INTO statement would
               be shown below:
                INSERT INTO cus_tbl (cus_id, cus_fname, cus_lname) VALUES (101, ‘Christian’, ‘Langit’),
                                                (102, ‘Bobet’, ‘Bubwitan’);







               MySQL SELECT
                       The MySQL SELECT statement is used to fetch the data from a database table which
               returns this data om the form of a result table. We can also say that the SELECT statement is
               used to select data from a database. Below is the syntax for SELECT command.
                                   SELECT column1, column2, …. FROM table_name;

               Here, column1 and column2 are the fields of a table whose values you want to fetch.
               If you want to select all the fields available in the table, use the following syntax:
                                              SELECT * FROM table_name;









                                                                                                  Page | 9
   88   89   90   91   92   93   94   95   96   97   98