0% found this document useful (0 votes)
4 views4 pages

Table 3

The document provides a step-by-step guide on creating a database named 'BCD' and a table 'TEACHER' in MySQL, including the structure of the table and sample data insertion. It also includes various SQL queries to retrieve specific information from the 'TEACHER' table, such as filtering by department and salary, and ordering results. Overall, it serves as a practical example of basic database operations and queries in 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)
4 views4 pages

Table 3

The document provides a step-by-step guide on creating a database named 'BCD' and a table 'TEACHER' in MySQL, including the structure of the table and sample data insertion. It also includes various SQL queries to retrieve specific information from the 'TEACHER' table, such as filtering by department and salary, and ordering results. Overall, it serves as a practical example of basic database operations and queries in 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/ 4

Creating Database and Table 3

mysql> CREATE DATABASE BCD;


Query OK, 1 row affected (0.01 sec)

mysql> USE ABC;


Database changed

mysql> CREATE TABLE TEACHER (No INT(1), Name VARCHAR(25), Age INT(2),
Department VARCHAR(15), DOJ DATE, Salary INT(7));
Query OK, 0 rows affected, 3 warnings (0.03 sec)

mysql> DESC TEACHER;


INSERTING DATA IN TABLE
mysql> INSERT INTO TEACHER VALUES(1, 'Sharmila', 33, 'Maths', 19970110,
12000);
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO TEACHER VALUES(2, 'Nitu', 40, 'English', 19960324,


18000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(3, 'Rakhi', 38, 'Computer', 19951212,


20000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(4, 'Neelam', 35, 'Maths', 19970905,


18000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(5, 'Kanchan', 31, 'History', 19960627,


25000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(6, 'Yasim', 36, 'History', 19970731,


30000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(7, 'Mansih', 50, 'English', 19950404,


25000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(8, 'Ankur', 37, 'Computer', 19980825,


18000);
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEACHER VALUES(9, 'Amarkant', 33, 'Maths', 19961015,


30000);
Query OK, 1 row affected (0.00 sec)
Queries
1. To Show all the records.

mysql> SELECT * FROM TEACHER;

2. To Show all information about the teacher in the History


Department.

mysql> SELECT * FROM TEACHER WHERE DEPARTMENT LIKE 'H%';

3. To list all the names of the Teachers who are in Maths Department
and Salary is More than 15000.

mysql> SELECT * FROM TEACHER WHERE DEPARTMENT LIKE 'M%' and Salary>
15000;
4. To list the names of all teachers with their date of joining in
ascending Order.

mysql> SELECT NAME, DOJ FROM TEACHER ORDER BY DOJ;

5. To list the report in an order where the list should contain the
Name of the teacher first, after that date of joining and then the
department. Also, the names should be arranged in ascending order.

mysql> SELECT NAME, DOJ, DEPARTMENT FROM TEACHER ORDER BY NAME;

You might also like