Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 28 - Modular_V2.0_SQL_Flipbook
P. 28

    INSERT INTO Students VALUES (10003, 'Aadarsh', 'Kumar', 475, '22/12, Sarita
                       Vihar, New Delhi');

                  You can also try bulk insertion like
                       INSERT INTO Students VALUES

                       ( 10001, 'Amit', 'Sharma', 450, 'E-458, Vikas Puri, New Delhi'),
                       (10002, 'Divya', 'Kaushik', 480, '9, Ansari Road, Daryaganj, New Delhi'),

                       (10003, 'Aadarsh', 'Kumar', 475, '22/12, Sarita Vihar, New Delhi' );
                  This will add the above data in one go into the table Students.

                  You can also insert values in the selective fields of the table. To do so, you need to specify the field
                  names with the table name in parenthesis. The syntax is as follows:

                       INSERT INTO table_name (column1, column2, .... columnN)
                       VALUES ('val_column1', 'val_column2', ... , 'val_columnN');

                  Ensure that the order of the values should be the same as the column names. For example,
                       INSERT INTO Students(First_name, Last_name) VALUES ('Dishu', 'Gupta');

                  In the preceding command, you have inserted values in the two columns only.

                       RETRIEVING RECORDS FROM A TABLE

                  The SELECT command retrieves zero or more rows from the table. It helps us to join information
                  from different tables and filter specific information as per the required criteria.

                  The syntax to use the SELECT command:

                       SELECT * FROM table_name;
                  Where * is used to select all the columns of the specified table.

                  To display all the data in the table:

                       SELECT * FROM Students;
                  The preceding command will display the following output:
                   +------------+------------+-----------+-------+--------------------------------+
                   | Student_id | First_name | Last_name | Marks | Address                        |
                   +------------+------------+-----------+-------+--------------------------------+
                   | 10001      | Amit       | Sharma    | 450   | E-458, Vikas Puri, New Delhi   |
                   | 10002      | Divya      | Kaushik   | 480   | 9, Ansari Road, Daryaganj,     |
                   |            |            |           |       | New Delhi                      |
                   | 10003      | Aadarsh    | Kumar     | 475   | 22/12, Sarita Vihar, New Delhi |
                   | NULL       | Dishu      | Gupta     | NULL  | NULL                           |
                   +------------+------------+-----------+-------+--------------------------------+
                  You can also retrieve selective records from a table by using the SELECT command. To do so, you
                  need to specify the name of the fields in place of *. For example, if you want to select only First_name
                  and Last_name fields from the Students table, then the SELECT command will be as follows:

                       SELECT First_name, Last_name from Students;

                    26
                          Touchpad MODULAR (Ver. 2.0)

| 23 24 25 26 27 28 29 30 31 32 33 |