Page 342 - TP_IT_V1.0_C10_flipbpookl
P. 342
OR
SELECT ROLLNO,NAME,DOB FROM student WHERE MARKS BETWEEN 80 AND 90;
+--------+---------------+------------+
| ROLLNO | NAME | DOB |
+--------+---------------+------------+
| 35 | Sikha Arora | 2004-12-15 |
| 12 | Debrath Singh | 2010-10-27 |
+--------+---------------+------------+
Using like operator
Like operator is used with WHERE clause to search for a specific pattern in a column.
It can be used with two wildcard characters:
• The percent sign (%) represents zero, one, or more characters
• The underscore sign (_) represents one character
To display rollno, name and fees of those students whose names end with ‘a’.
SELECT ROLLNO,NAME,FEES FROM STUDENT WHERE NAME LIKE '%a';
+--------+--------------+------+
| ROLLNO | NAME | FEES |
+--------+--------------+------+
| 35 | Sikha Arora | 8800 |
| 8 | Aparna Aneja | 9000 |
+--------+--------------+------+
To display records of those students whose names start with ‘A’.
SELECT * FROM STUDENT WHERE NAME LIKE “A%”;
+--------+--------------+------+------------+-------+----------+
| RollNo | Name | Fees | DOB | Marks | ClassSec |
+--------+--------------+------+------------+-------+----------+
| 8 | Aparna Aneja | 9000 | 2006-09-24 | 92 | 10A |
+--------+--------------+------+------------+-------+----------+
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)
340 Trackpad Information Technology (Ver. 1.0)-X

