0% found this document useful (0 votes)
6 views3 pages

Table 7

The document details the creation of a MySQL database named 'ABC' and a table 'STUDENT' with fields for student information. It includes various SQL queries to display records, filter by class, and retrieve specific student details. The results of these queries show data for five students, including their roll numbers, names, classes, fees, and percentages.

Uploaded by

jangratanisha26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Table 7

The document details the creation of a MySQL database named 'ABC' and a table 'STUDENT' with fields for student information. It includes various SQL queries to display records, filter by class, and retrieve specific student details. The results of these queries show data for five students, including their roll numbers, names, classes, fees, and percentages.

Uploaded by

jangratanisha26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Creating Database and Table 7

mysql> CREATE DATABASE ABC;


Query OK, 1 row affected (0.01 sec)

mysql> USE ABC;


Database changed

mysql> CREATE TABLE STUDENT (Roll_No INT, Name VARCHAR(15), Class


VARCHAR(3), Fee INT(5), Percentage INT(3));
Query OK, 0 rows affected, 2 warnings (0.03 sec)

mysql> DESC STUDENT;


+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| Roll_No | int | YES | | NULL | |
| Name | varchar(15) | YES | | NULL | |
| Class | varchar(3) | YES | | NULL | |
| Fee | int | YES | | NULL | |
| Percentage | int | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)
Queries
1. Display all the Records.

mysql> SELECT * FROM STUDENT;


+---------+-----------+-------+------+------------+
| Roll_No | Name | Class | Fee | Percentage |
+---------+-----------+-------+------+------------+
| 1 | POONAM | X | 5000 | 75 |
| 2 | NEELAM | XI | 2500 | 56 |
| 3 | KANCHAN | X | 3700 | 83 |
| 4 | RAJ_KUMAR | XI | 4200 | 60 |
| 5 | KHUSHBOO | X | 4500 | 77 |
+---------+-----------+-------+------+------------+
5 rows in set (0.00 sec)

2. Display Roll_No, Name, and Class of the Table.

mysql> SELECT Roll_No, Name, CLASS FROM STUDENT;


+---------+-----------+-------+
| Roll_No | Name | CLASS |
+---------+-----------+-------+
| 1 | POONAM | X |
| 2 | NEELAM | XI |
| 3 | KANCHAN | X |
| 4 | RAJ_KUMAR | XI |
| 5 | KHUSHBOO | X |
+---------+-----------+-------+
5 rows in set (0.00 sec)

3. Display records of student ‘KANCHAN’.

mysql> SELECT * FROM STUDENT WHERE NAME='KANCHAN';

+---------+---------+-------+------+------------+
| Roll_No | Name | Class | Fee | Percentage |
+---------+---------+-------+------+------------+
| 3 | KANCHAN | X | 3700 | 83 |
+---------+---------+-------+------+------------+
1 row in set (0.00 sec)

4. Display records of students of Class X.


mysql> SELECT * FROM STUDENT WHERE CLASS='X';
+---------+----------+-------+------+------------+
| Roll_No | Name | Class | Fee | Percentage |
+---------+----------+-------+------+------------+
| 1 | POONAM | X | 5000 | 75 |
| 3 | KANCHAN | X | 3700 | 83 |
| 5 | KHUSHBOO | X | 4500 | 77 |
+---------+----------+-------+------+------------+
3 rows in set (0.00 sec)

5. Display records of students paying fees more than 3500.

mysql> SELECT * FROM STUDENT WHERE Fee > 3500;


+---------+-----------+-------+------+------------+
| Roll_No | Name | Class | Fee | Percentage |
+---------+-----------+-------+------+------------+
| 1 | POONAM | X | 5000 | 75 |
| 3 | KANCHAN | X | 3700 | 83 |
| 4 | RAJ_KUMAR | XI | 4200 | 60 |
| 5 | KHUSHBOO | X | 4500 | 77 |
+---------+-----------+-------+------+------------+
4 rows in set (0.00 sec)

6. Display fee of RAJ_KUMAR.

mysql> SELECT Fee FROM STUDENT WHERE NAME='RAJ_KUMAR';


+------+
| Fee |
+------+
| 4200 |
+------+
1 row in set (0.00 sec)

You might also like