Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 30 - Modular_V2.0_SQL_Flipbook
P. 30

    Let us change the marks of the student having 10002 as StudentID from 480 to 485 by using the
                  following command:

                       UPDATE Students SET Marks = 485 where Student_id = 10002;

                       DELETING RECORDS FROM A TABLE
                  The DELETE command is used to remove records from a table. The DELETE command can be used
                  in two ways:

                      Without WHERE clause                     With the WHERE clause
                  You can remove a specific record by using the WHERE clause with the DELETE command. If you use
                  the DELETE command without the WHERE clause, it will remove all the records from the table. Let us
                  use the DELETE command to remove the record of a student whose LastName is Kumar:

                       DELETE FROM Students WHERE Last_name="Kumar";
                  To remove all the records, following command is used:
                                                                             Tech Funda
                       DELETE FROM Students;
                       USING DISTINCT CLAUSE
                                                                          TRUNCATE TABLE empties a table
                  The DISTINCT clause is used with the SELECT
                                                                          completely.
                  command to display the unique values of a
                  column.

                  The  syntax  of  the  DISTINCT clause  is as
                  follows:
                       SELECT DISTINCT <column_name > FROM <table_name>;
                  For Example,

                       SELECT DISTINCT COST FROM OFFICE;
                                      +------+
                                      | COST |                  Hands On
                                      +------+
                                      |  20  |
                                      +------+                   Create an Orders table with columns: OrderID,
                                      |  10  |                   CustomerID, and Product. Insert some records
                                      +------+
                                      |  45  |                   with duplicate product names. Then, write a query
                                      +------+                   using the  DISTINCT clause to retrieve unique
                                      | 120  |
                                      +------+                   product names from the Orders table.
                                      |  30  |
                                      +------+
                       USING OPERATORS

                  SQL  statements  consist of  reserved  words  or  symbols which  are  used  to  perform  arithmetical
                  operations, comparisons, etc. These reserved words or symbols are called as ‘Operators’.
                  The three types of operators in SQL are:

                      Relational Operators
                      Boolean Operators

                      Special Operators
                  Let us learn about them.

                    28
                          Touchpad MODULAR (Ver. 2.0)

| 25 26 27 28 29 30 31 32 33 34 35 |