0% found this document useful (0 votes)
11 views5 pages

Table 2

The document outlines the process of creating a database named 'ABC' and a table within it, including the structure of the table and the insertion of various student records. It also includes several SQL queries to retrieve specific information from the table, such as student names, rankings, subjects, and stipends. The document serves as a practical guide for managing and querying a simple database using MySQL.

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)
11 views5 pages

Table 2

The document outlines the process of creating a database named 'ABC' and a table within it, including the structure of the table and the insertion of various student records. It also includes several SQL queries to retrieve specific information from the table, such as student names, rankings, subjects, and stipends. The document serves as a practical guide for managing and querying a simple database using MySQL.

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/ 5

Creating Database and Table 2

mysql> CREATE DATABASE ABC;


Query OK, 1 row affected (0.01 sec)

mysql> USE ABC;


Database changed

mysql> CREATE TABLE ABC (S_No INT NOT NULL, NAME VARCHAR(10), SUBJECT VARCHAR(15),
STIPEND INT(4), AVG INT(4), GRADE INT(2));
Query OK, 0 rows affected, 3 warnings (0.03 sec)

mysql> DESC ABC;

INSERTING DATA IN TABLE


mysql> INSERT INTO ABC VALUES(1, 'HARSH', 'COMPUTER', 250, 68, 1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(2, 'KAMAL', 'PHYSICS', 400, 72, 1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(3, 'ARUN', 'COMPUTER', 350, 45, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(4, 'DIWAKAR', 'CHEMISTRY', 300, 73, 1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(5, 'RAJU', 'MATHS', 300, 70, 1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(6, 'ROBERT', 'MATHS', 500, 65, 2);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO ABC VALUES(7, 'SHOAIB', 'COMPUTER', 450, 66, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(8, 'WASIM', 'PHYSICS', 250, 68, 2);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(9, 'VIKAS', 'CHEMISTRY', 350, 45, 1);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO ABC VALUES(10, 'ARJUN', 'COMPUTER', 400, 70, 1);
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM ABC;


Queries
1. List only names of all the students

mysql> SELECT NAME FROM ABC;

2. List the names of those students who have obtained Rank 1 sored by Name in
Ascending order

mysql> SELECT * FROM ABC WHERE GRADE=1 ORDER BY NAME;


3. List the name of those students who are having Computer as a subject

mysql> SELECT * FROM ABC WHERE SUBJECT= 'COMPUTER';

4. List all students sorted by Stipend in Descending order

mysql> SELECT * FROM ABC ORDER BY STIPEND DESC;


5. Query to show Name, Stipend, Subject whose Avg is more than 50 and Grade is 1

mysql> SELECT NAME, STIPEND, SUBJECT FROM ABC WHERE AVG> 50 AND GRADE=1;

You might also like