Page 334 - IT 402 v2.0 class 10
P. 334
The preceding command will display the following output:
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
| Stu d entI D | F ir stName | L astName | M ar k s |
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
| 1 0 0 0 1 | Amit | Shar ma | 4 5 0 |
| 1 0 0 0 2 | D iv y a | K au shik | 4 5 0 |
| 1 0 0 0 3 | Aad ar sh | K u mar | 4 5 0 |
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
To get details of the list of students whose LASTNAME is Kumar:
SE L E CT * F RO M Stu d ent W H E RE L astName = " K u mar " ;
The preceding command will display the following output:
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
|
| Stu d entI D F ir stName | L astName M ar k s |
|
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
| 1 0 0 0 3 | Aad ar sh | K u mar | 4 5 0 |
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
To get details of the list of students in ascending order of FirstName:
SELECT * FROM Student ORDER BY FirstName ASC;
The preceding command will display the following output:
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
| Stu d entI D | F ir stName | L astName | M ar k s |
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
| 1 0 0 0 3 | Aad ar sh | K u mar | 4 5 0 |
| 1 0 0 0 2 | D iv y a | K au shik | 4 5 0 |
| 1 0 0 0 1 | Amit | Shar ma | 4 5 0 |
+ - - - - - - - - - - - + - - - - - - - - - - - + - - - - - - - - - - + - - - - - - - +
e can also us the wildcards and with the S command to specify conditions. he wildcard
denotes a single character on the other hand the wildcard denotes the multiple characters:
SE L E CT F ir stName, M ar k s F RO M Stu d ent W H E RE L astName lik e ' K % ' ;
+ - - - - - - - - - - - + - - - - - - - +
| F ir stName | M ar k s |
+ - - - - - - - - - - - + - - - - - - - +
| D iv y a | 4 5 0 |
| Aad ar sh | 4 5 0 |
+ - - - - - - - - - - - + - - - - - - - +
SE L E CT M ar k s F RO M Stu d ent W H E RE F ir stName lik e ' A% ' ;
+ - - - - - - - +
| M ar k s |
+ - - - - - - - +
| 4 5 0 |
+ - - - - - - - +
USING DISTINCT CLAUSE
The DISTINCT clause is used with the SELECT command to display the unique values a column. The syntax of
the DISTINCT clause is as follows:
SE L E CT D I ST I NCT CO ST F RO M O F F I CE ;
332 Touchpad Information Technology-X

