Page 301 - Trackpad 402_Class-X_Final
P. 301

To display Name and class of those students whose second alphabet is ‘a’.


            SELECT NAME,CLASSSEC FROM STUDENT WHERE NAME LIKE  ‘_A%’;
            +-------------+----------+
            | NAME        | CLASSSEC |
            +-------------+----------+
            | Jaya Kapoor | 11C      |
            +-------------+----------+
            Displaying arranged data
            Arranging the data in ascending or descending order of one/multiple columns. Use ASC(Default) for ascending, DESC
            for descending (use of ORDER BY clause with SELECT)

            Syntax:

            SELECT */<Col1>,<Col2>, ... <Col N>
            FROM <Table Name> ORDER BY <Col1> [ASC/DESC],<Col2> [ASC/DESC],... ;

            SELECT * FROM STUDENT ORDER BY Name ASC;
            +--------+---------------+------+------------+-------+----------+
            | RollNo | Name          | Fees | DOB        | Marks | ClassSec |
            +--------+---------------+------+------------+-------+----------+
            |      8 | Aparna Aneja  | 9000 | 2006-09-24 |    92 | 10A      |
            |     35 | Sikha Arora   | 8800 | 2004-12-15 |    87 | 9D       |
            |     12 | Debrath Singh | 8600 | 2010-10-27 |    92 | 10A      |

            |     14 | Jaya Kapoor   | 7800 | 2008-03-08 |    78 | 11C      |
            +--------+---------------+------+------------+-------+----------+
            SELECT * FROM Student ORDER BY Fees DESC;
            +--------+---------------+------+------------+-------+----------+
            | RollNo | Name          | Fees | DOB        | Marks | ClassSec |
            +--------+---------------+------+------------+-------+----------+
            |      8 | Aparna Aneja  | 9000 | 2006-09-24 |    92 | 10A      |
            |     35 | Sikha Arora   | 8800 | 2004-12-15 |    87 | 9D       |
            |     12 | Debrath Singh | 8600 | 2010-10-27 |    92 | 10A      |
            |     14 | Jaya Kapoor   | 7800 | 2008-03-08 |    78 | 11C      |
            +--------+---------------+------+------------+-------+----------+
            The syntax for deleting a row/rows from a table is as follows:

            DELETE FROM <Table Name> [WHERE <Condition> ];
            For example,

            DELETE FROM Student WHERE RollNo=12
            To delete all rows of a table (Does not delete the structure of the table)
            DELETE FROM Student;








                                                                                   Database  Management System  301
   296   297   298   299   300   301   302   303   304   305   306