0% found this document useful (0 votes)
2 views49 pages

Ranjit H

The document outlines SQL commands for creating and manipulating tables for teachers, students, companies, customers, and doctors. It includes specific commands for querying and updating data, such as displaying records based on conditions, altering tables, and calculating averages. Each section concludes with a confirmation of successful execution of the SQL commands.

Uploaded by

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

Ranjit H

The document outlines SQL commands for creating and manipulating tables for teachers, students, companies, customers, and doctors. It includes specific commands for querying and updating data, such as displaying records based on conditions, altering tables, and calculating averages. Each section concludes with a confirmation of successful execution of the SQL commands.

Uploaded by

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

DATE : PROGRAM NO : 18

TEACHER

AIM:
To create table for teacher and execute the given commands using SQL.

TABLE: TEACHER

No Name Age Department DateofJoin Salary Sex


1 Jishnu 34 Computer 10/01/97 12000 M
2 Sharmila 31 History 24/03/98 20000 F
3 Santhosh 32 Maths 12/12/96 30000 M
4 Shanmathi 35 History 01/07/99 40000 F
5 Ragu 42 Maths 05/09/97 25000 M
6 Shiva 50 History 27/02/97 30000 M
7 Shakthi 44 Computer 25/02/97 21000 M
8 Shriya 33 Maths 31/07/97 20000 F

1. To show all information about the teacher of history department.


2. To list the names of female teacher who are in Maths department.
3. To list names of all teachers with their date of joining in ascending order.
4. To count the number of teachers with age>35.
5. To count the number of teachers department wise.

SQL Commands:

CREATING TABLE TEACHER:

CREATE TABLE TEACHER(No int(2), Name varchar(15), Age int(3) , Department


varchar(15), Dateofjoin varchar(15) , Salary int(7) , Sex char(1));

INSERTING VALUES INTO TEACHER TABLE:

INSERT INTO TEACHER VALUES(1,’Jishnu’,34,’Computer’,’10/01/97’,12000,’M’);

36
OUTPUT:

1. select * from teacher where Department=’History’;


No Name Age Department DateofJoin Salary Sex
2 Sharmila 31 History 24/03/98 20000 F
4 Shanmathi 35 History 01/07/99 40000 F
6 Shiva 50 History 27/02/97 30000 M

2. select Name from teacher where Department=’Maths’ and Sex=’F’;


Name
Shriya

3. select Name , Dateofjoin from teacher order by Dateofjoin;

Name Dateofjoin
Santhosh 12/12/96
Jishnu 10/01/97
Shakthi 25/02/97
Shiva 27/02/97
Shriya 31/07/97
Ragu 05/09/97
Sharmila 24/03/98
Shamathi 01/07/99

4. select count(*) from teacher where Age>35;

5. select Department , count(*) from teacher group by department;

Department Count(*)

Computer 2

History 3

Maths 3

RESULT:
Thus the given program executed successfully.

37
DATE : PROGRAM NO : 19
STUDENT

AIM:
To create table for Student and execute the given commands using SQL.

TABLE: STUDENT
No Name Stipend Stream AvgMark Grade Class
1 Karan 400.00 Science 78.5 B 12B
2 Divakar 450.00 Science 89.2 A 11C
3 Divya 300.00 Commerce 68.6 C 12A
4 Arun 350.00 Commerce 73.1 B 12C
5 Robert 500.00 Humanities 90.6 A 11A
6 Sabina 400.00 Humanities 75.4 B 12A
7 Rubina 350.00 Science 64.4 C 12B
8 Vikas 450.00 Commerce 88.5 A 11B
9 John 500.00 Science 92.0 A 12A
10 Mohan 300.00 Commerce 67.5 C 12C

1. Alter Table to add new column DOB Date in Student Table.


2. Alter Table to change No Column to Roll NO also data size change.
3. Select all the Science stream students from STUDENT.
4. List all students sorted by AvgMark in Descending order.
5. Show Mohan Stipend is Greater than 200 or not.

SQL Commands:

CREATING TABLE STUDENT:

CREATE TABLE STUDENT(No int(2), Name varchar(15), Stipend Decimal(10,2) ,


Stream varchar(15), AvgMark Decimal(5,2), Grade Char(1) , Class Varchar(5));

INSERTING VALUES INTO STUDENT TABLE:

INSERT INTO STUDENT VALUES(1,’Karan’,400.00,’Science’,78.5,’B’,’12B’);

38
OUTPUT:

1. Alter Table student add (DOB Date);


Mysql>Select * from student;

No Name Stipend Stream AvgMark Grade Class DOB


1 Karan 400.00 Science 78.5 B 12B
2 Divakar 450.00 Science 89.2 A 11C
3 Divya 300.00 Commerce 68.6 C 12A
4 Arun 350.00 Commerce 73.1 B 12C
5 Robert 500.00 Humanities 90.6 A 11A
6 Sabina 400.00 Humanities 75.4 B 12A
7 Rubina 350.00 Science 64.4 C 12B
8 Vikas 450.00 Commerce 88.5 A 11B
9 John 500.00 Science 92.0 A 12A
10 Mohan 300.00 Commerce 67.5 C 12C

2. Alter Table student change No RollNo Int(10);


Mysql>Describe student;

Field Type Null Key Default Extra


RollNo Int(10) YES NULL
Name Varchar(15) YES NULL
Stipend Decimal(10,2) YES NULL
Stream Varchar(15) YES NULL
AvgMark Decimal(5,2) YES NULL
Grade Char(1) YES NULL
Class Varchar(5) YES NULL

3. Select * from student where stream like ‘Science’;

No Name Stipend Stream AvgMark Grade Class DOB


1 Karan 400.00 Science 78.5 B 12B
2 Divakar 450.00 Science 89.2 A 11C
7 Rubina 350.00 Science 64.4 C 12B
9 John 500.00 Science 92.0 A 12A

39
4. Select * from student student order by AvgMark Desc;

No Name Stipend Stream AvgMark Grade Class DOB


9 John 500 Science 92 A 12A
5 Robert 500 Humanities 90.6 A 11A
2 Divakar 450 Science 89.2 A 11C
8 Vikas 450 Commerce 88.5 A 11B
1 Karan 400 Science 78.5 B 12B
6 Sabina 400 Humanities 75.4 B 12A
4 Arun 350 Commerce 73.1 B 12C
3 Divya 300 Commerce 68.6 C 12A
10 Mohan 300 Commerce 67.5 C 12C
7 Rubina 350 Science 64.4 C 12B

5. Select Name, Stipend from student where Name =’Mohan’ and Stipend > 200;

Name Stipend
Mohan 300.00

RESULT:
Thus the given program executed successfully.

40
DATE : PROGRAM NO : 20
COMPANY AND CUSTOMER

AIM:
To create two tables, company and customer and execute the given commands using SQL.

TABLE : COMPANY

CID NAME CITY PRODUCTNAME


111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY MADRAS MOBILE
666 CELL DELHI LAPTOP

TABLE : CUSTOMER

CUSTID NAME PRICE QTY CID

101 ROHAN SHARMA 70000 20 222

102 DEEPAK KUMAR 50000 10 666


103 MOHAN KUMAR 30000 5 111

104 SAHIL BANSAL 35000 3 333

105 NEHA SONI 25000 7 444

106 SONAL AGGARWAL 20000 5 333

1. To display those company name which are having price less than 30000.
2. To display the name of the companies in reverse alphabetical order.
3. To increase the price by 1000 for those customer whose name starts with ‘S’
4. To add one more column totalprice with decimal (10,2) to the table customer
5. To display the details of company where productname as mobile.

41
SQL Commands:

CREATING TABLE COMPANY:

CREATE TABLE COMPANY(cid int(3) , name varchar(15) , city varchar(10), productname


varchar(15));

INSERTING VALUES INTO TABLE COMPANY:

INSERT INTO COMPANY VALUES (111, ‘SONY’, ‘DELHI’, ‘TV’), (222,


‘NOKIA’, ‘MUMBAI’, ‘MOBILE’), (333, ‘ONIDA’, ‘DELHI’, ‘TV’), (444, ‘SONY’, ‘MUMBAI’,
‘MOBILE’), (555, ‘BLACKBERRY’, ‘MADRAS’, ‘MOBILE’), (666, ‘CELL’, ‘DELHI’,
‘LAPTOP’);

CREATING TABLE CUSTOMER:

CREATE TABLE CUSTOMER (custid int(3), name varchar(15), price int(10), qty int(3) , cid int(3));

INSERTING VALUES INTO TABLE CUSTOMER:

INSERT INTO CUSTOMER VALUES (101, ‘ROHAN SHARMA’, 70000, 20, 222), (102, ‘DEEPAK
KUMAR’, 50000, 10, 666), (103, ‘MOHAN KUMAR’, 30000, 5, 111), (104, ‘SAHIL BANSAL’,
35000, 3, 333), (104, ‘NEHA SONI’, 25000, 7, 444), (106, ‘SONAL AGGARWAL’, 20000, 5, 333);

OUTPUT :

1. select name from company where company.cid=customer. cid and price < 30000;

NAME
NEHA SONI

2. select name from company order by name desc;

NAME
SONY
ONIDA
NOKIA
DELL
BLACKBERRY
3. update customer set price = price + 1000 where name like ‘s%’; select * from customer;

CUSTID NAME PRICE QTY CID

101 ROHAN SHARMA 70000 20 222

102 DEEPAK KUMAR 50000 10 666

42
103 MOHAN KUMAR 30000 5 111

104 SAHIL BANSAL 36000 3 333

105 NEHA SONI 25000 7 444

106 SONAL AGGARWAL 21000 5 333

4. alter table customer add totalprice decimal(10,2); Select * from customer;

CUSTID NAME PRICE QTY CID TOTALPRICE

101 ROHAN SHARMA 70000 20 222 NULL


102 DEEPAK KUMAR 50000 10 666 NULL
103 MOHAN KUMAR 30000 5 111 NULL
104 SAHIL BANSAL 36000 3 333 NULL
105 NEHA SONI 25000 7 444 NULL
106 SONAL AGGARWAL 21000 5 333 NULL

5. select * from company where productname=’mobile’;

CID NAME CITY PRODUCTNAME

222 NOKIA MUMBAI MOBILE

444 SONY MUMBAI MOBILE

555 BLACKBERRY MADRAS MOBILE

RESULT:
Thus the given program executed successfully.

43
DATE : PROGRAM NO : 21
DOCTOR AND SALARY

AIM:
To create two tables for doctor and salary and execute the given commands using SQL.

TABLE:DOCTOR

TABLE: SALARY

i) Display NAME of all doctors who are in “MEDICINE” having more than 10 years
experience from table DOCTOR.
ii) Display the average salary of all doctors working in “ENT” department using the
tables DOCTOR and SALARY. (Salary=BASIC+ALLOWANCE)
iii) Display minimum ALLOWANCE of female doctors.
iv) Display DOCTOR.ID , NAME from the table DOCTOR and BASIC , ALLOWANCE from
the table SALARY with their corresponding matching ID.
v) To display distinct department from the table doctor.

44
SQL Commands:

CREATING TABLE DOCTOR:

CREATE TABLE DOCTOR(ID int NOT NULL PRIMARY KEY, NAME char(25) , DEPT char(25) ,
SEX char , EXPERIENCE int);

INSERTING VALUES INTO TABLE DOCTOR:

INSERT INTO DOCTOR VALUES(101,”John”, “ENT”,’M’,12), (104,”Smith”,


“ORTHOPEDIC”,’M’,5), (107,”George”, “CARDIOLOGY”,’M’,10), (114,”Lara”, “SKIN”,’F’,3),
(109,”K George”, “MEDICINE”,’F’,9), (105,”Johnson”, “ORTHOPEDIC”,’M’,10), (117,”Lucy”,
“ENT”,’F’,3), (111,”Bill”, “MEDICINE”,’F’,12), (130,”Morphy”, “ORTHOPEDIC”,’M’,15);

CREATING TABLE SALARY:

CREATE TABLE SALARY(ID int, BASIC int, ALLOWANCE int, CONSULTATION int);

INSERTING VALUES INTO TABLE SALARY:

INSERT INTO SALARY VLAUES (101, 12000,1000,300), (104, 23000,2300,500), (107, 32000,
4000, 500), (114, 12000, 5200, 100), (109,42000, 1700,200), (105, 18900, 1690, 300), (130, 21700,
2600, 300)

OUTPUT:

i) select NAME from DOCTOR where DEPT=”MEDICINE” and EXPERIENCE >10;

ii) select avg(BASIC+ALLOWANCE) “avg salary” from DOCTOR , SALARY where


DOCTOR.ID=SALARY.ID and DEPT=”ENT”;

iii) select min(ALLOWANCE) from SALARY, DOCTOR where SEX=’F’ and


DOCTOR.ID=SALARY.ID;

45
iv) select DOCTOR.ID, NAME, BASIC ,ALLOWANCE from DOCTOR,SALARY where
DOCTOR.ID=SALARY.ID;

v) select distinct(DEPT) from DOCTOR;

RESULT:
Thus the given program executed successfully

46
DATE : PROGRAM NO : 22

SQL Connecting – I ( Creating & Insertion)

Aim:
To write a program to perform creation and insertion operations with reference to table
“Employee” through MySQL – Python Connectivity.

Source code:
import mysql.connector as mysql
db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="c12" )
cursor = db1.cursor()
try:
sql = "CREATE TABLE EMPSNEW(empno integer primary key,ename varchar(25) not null,salary
float);"
cursor.execute(sql)
print("Table created successfully")
except:
print("Table already exists")
sql = "INSERT INTO EMPSNEW VALUES (1,'Arun',80000),(2,'Vinu',75000),(3,'Neeru',81000);"
cursor.execute(sql)
print("Values inserted successfully")
try:
sql = "select * from EMPSNEW;"
cursor.execute(sql)
resultset = cursor.fetchall()
for row in resultset:
print (row)
db1.commit()
print("success")

except:
print("err")
db1.rollback()
db1.close()

47
OUTPUT:

48
DATE : PROGRAM NO : 23
SQL Connectivity – II ( Searching)

Aim:
To write a program to perform searching operations with reference to table “Employee”
through MySQL – Python Connectivity.

Source code:
Fetching all the records from EMPSNEW table having salary less than 80000.

import mysql.connector as mysql


db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="c12" )
cursor = db1.cursor()
sql = "SELECT * FROM EMPSNEW WHERE SALARY < 80000;"
try:
cursor.execute(sql)
print("# before fetch")
resultset = cursor.fetchall()
for row in resultset:
print (row)
print("# after fetch")
except:
print ("Error: unable to fetch data")
db1.close()

49
Output:

50
DATE : PROGRAM NO : 24
SQL Connectivity – III ( Updating)

Aim:
To write a program to perform updating operations with reference to table “Employee”
through MySQL – Python Connectivity.

Source code:

import mysql.connector as mysql


db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="c12" )
if db1.is_connected():
print("py->SQL connected")
cursor = db1.cursor()
sql = "UPDATE EMPSNEW SET salary = salary +1000 WHERE salary<80000;"
try:
print('before execution')
cursor.execute(sql)
db1.commit()
print('after execution')
sql = "select * from EMPSNEW;"
cursor.execute(sql)
resultset = cursor.fetchall()
for row in resultset:
print (row)
db1.commit()
print("success")

except:
db1.rollback()
db1.close()

51
OUTPUT:

52
DATE : PROGRAM NO : 8
Write a Program to print all the line starting with letter ‘T’.

Aim:
To write a Program to print all the line starting with letter ‘T’.

Source Code:

53
Output:

54
DATE : PROGRAM NO : 9
Write a Program to count the number of occurrence of ‘is’ and ‘and’ in a text
file.

Aim:
To write a program to count the number of occurrence of ‘is’ and ‘and’ in a text file.

Source Code:

55
Output:

56
DATE : PROGRAM NO : 10
Write a Program to count vowels, consonants, digits, special character, lower
case & upper case letters present in text file.

Aim:
To write a program to count vowels, consonants, digits, special character, lower case &
upper case letters present in text file.

Source Code:

57
Output:

58
DATE : PROGRAM NO : 11
Write a Program to read a text file and create a new file after adding ‘ing’ to all words
ending with ‘s’ and ‘d’.

Aim:
To write a program to read a text file and create a new file after adding ‘ing’ to all
words ending with ‘s’ and ‘d’.

Source Code:

59
Output:

60
DATE : PROGRAM NO : 12
Write a Program to store and retrieving students information using CSV
file.

Aim:
To write a program to store and retrieving students information using CSV file.

Source Code:

61
Output:

62
DATE : PROGRAM NO : 13
Write a Program to copy the content of one CSV file to another by using different
delimiter.

Aim:
To write a program to copy the content of one CSV file to another by using different delimiter.

Source Code:

63
Output:

64
DATE : PROGRAM NO : 14
Write a Program to search and display using binary file.

Aim:
To write a program to search and display using binary file.

Source Code:

65
Output:

66
DATE : PROGRAM NO : 15
Write a menu driven program to write/read/update and append data onto a binary file.

Aim:
Write a menu driven program to write/read/update and append data onto a binary file.

Source Code:

67
Output:

68
DATE : PROGRAM NO : 16
Write a Python program to implement all basic operations of a stack, such
as adding element (PUSH operation), removing element (POP operation)
and displaying the stack elements (Traversal operation) using lists.

Aim:
Write a program to implement all basic operations of a stack, such as adding element (PUSH
operation), removing element (POP operation) and displaying the stack elements (Traversal
operation) using lists.

Source Code:
s=[]
c='y'
while(c=='y'):
print('1.PUSH')
print('2.POP')
print('3.DISPLAY')
choice=int(input('Enter your choice:'))
if(choice==1):
a=input('Enter any number')
s.append(a)
elif(choice==2):
if(s==[]):
print('Stack empty')
else:
print('Deleted element is:',s.pop())
elif(choice==3):
l=len(s)
for i in range(l-1,-1,-1):
print(s[i])
else:
print('Wrong input')
c=input('Do you want to continue or not?')

69
Output:

70
DATE : PROGRAM NO : 17

Aim:

Source Code:

71
Output:

72
DATE : PROGRAM NO : 18
SQL Connecting – I ( Creating & Insertion)

Aim:
To write a program to perform creation and insertion operations with reference to table
‘Employee’ through MySQL – Python connectivity.

Source Code:
import mysql.connector as mysql
db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="NK"
) cursor = db1.cursor()
sql = "CREATE TABLE EMPS(empno integer primary key,ename varchar(25) not null,salary
float);"
cursor.execute(sql)
sql = "INSERT INTO EMPS VALUES(1,'Liyash PS',86000),(2,'PK Aishawaryamana
Pillai',86500),(3,'Chottavicky',90000),(4,'RAAMU',99000),(5,'KARTHIK PRINZZ',92000)" ;
try:
cursor.execute(sql)
db1.commit()
except:
db1.rollback()
db1.close()

73
Output:

74
DATE : PROGRAM NO : 19
SQL Connectivity – II (Searching Operation)

Aim:
To write a program to perform searching operation with reference to table ‘Employee’ through
MySQL-Python connectivity
Fetching all the records from EMPS table having salary more than 70000.

Source Code:
import mysql.connector as mysql
db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="NK" )
cursor = db1.cursor()
sql = "SELECT * FROM EMPS WHERE SALARY > 70000;"
try:
cursor.execute(sql)

resultset = cursor.fetchall()
for row in resultset:
print (row)
except:
print ("Error: unable to fetch data")
db1.close()

75
Output:

76
DATE : PROGRAM NO : 20
SQL Connectivity – III ( Updating Operation)

Aim:
To write a program to perform updating operation with reference to table ‘Employee’ through
MySQL-Python connectivity

Source Code:
import mysql.connector as mysql
db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="NK" )
cursor = db1.cursor()
sql = "UPDATE EMPS SET salary = salary +1000 WHERE salary<80000;"
try:
cursor.execute(sql)
db1.commit()
except:
db1.rollback()
db1.close()

77
OUTPUT :

78
DATE : PROGRAM NO : 21
SQL CONNECTIVITY – IV (Deletion operation)

Aim:
To write a program to perform deletion operation with reference to table ‘Employee’ through
MySQL-Python connectivity

Deleting record(s) from table using DELETE


Source code :
import mysql.connector as mysql
db1 = mysql.connect(host="localhost",user="root",passwd="Student@123",database="NK" )
cursor = db1.cursor()
sal=int(input("Enter salary whose record to be deleted : "))
sql = "DELETE FROM EMP WHERE salary =sal”
try:
cursor.execute(sql)
print(cursor.rowcount, end=" record(s) deleted ")
db1.commit()
except:
db1.rollback()
db1.close()

79
OUTPUT:

80
DATE : PROGRAM NO : 22
Creating, inserting values, updating and display a table in many forms
using SQL Queries

AIM:
Creating, inserting values, updating and display a table in many forms using SQL Queries

Creating a table:

mysql> use mysql


Database changed

mysql> create table student(sid int(5), sname char(20), gender char(7), city char(30), phonenum
int(10));
Query OK, 0 rows affected (0.08 sec)

mysql> create table marks(sid int(5), Computer int, Physics int, Chemistry int, Biology int);
Query OK, 0 rows affected (0.08 sec)

Inserting values into table:

mysql> insert into student values(101,'Sathya','Male','Krishnagiri',2467453);


Query OK, 1 row affected (0.03 sec)

mysql> insert into student values (102,'Sindhu,'Female','Hosur',2467834),


(103,'Karthick','Male','Krishnagiri', 2389345), (104,'Anitha','Female','Salem', 2387865),
(105,'Vimal','Male','Dharmapuri', 2356895);
Query OK, 4 row affected (0.03 sec)
Records : 4 Duplicates : 0 Warnings : 0

mysql> insert into marks values (101,89,67,58,90), (102,78,98,65,45), (103,56,78,83,97),


(104,99,48,69,75), (105,87,82,79,60);
Query OK, 5 row affected (0.03 sec)
Records : 5 Duplicates : 0 Warnings : 0

81
Displaying a table:

mysql> select * from student;


sid sname gender city phonenum
101 Sathya Male Krishnagiri 2467453
102 Sindhu Female Hosur 2467834
103 Karthick Male Krishnagiri 2389345
104 Anitha Female Salem 2387865
105 Vimal Male Dharmapuri 2356895
5 rows in set (0.00 sec)

mysql> select * from marks;


sid Computer Physics Chemistry Biology
101 89 67 58 90
102 78 98 65 45
103 56 78 83 97
104 99 48 69 75
105 87 82 79 60
5 rows in set (0.00 sec)

Selecting Specific Rows using WHERE clause

mysql> select * from student where sid=103;


sid sname gender city phonenum
103 Karthick Male Krishnagiri 2389345
1 rows in set (0.03 sec)

Sorting Results - ORDER BY clause


mysql> select * from student order by sname desc;
sid sname gender city phonenum
105 Vimal Male Dharmapuri 2356895
102 Sindhu Female Hosur 2467834
101 Sathya Male Krishnagiri 2467453
103 Karthick Male Krishnagiri 2389345
104 Anitha Female Salem 2387865
5 rows in set (0.00 sec)

82
mysql> select * from student where gender='Male' order by sname;
sid sname gender city phonenum
103 Karthick Male Krishnagiri 2389345
101 Sathya Male Krishnagiri 2467453
105 Vimal Male Dharmapuri 2356895

3 rows in set (0.01 sec)

Aggregate Functions
mysql> select sum(Computer) from marks;
sum(Computer)
409
1 rows in set (0.03 sec)

mysql> select avg(Computer) from marks;


avg(Computer)
81.8000
1 rows in set (0.01 sec)

mysql> select count(*) from marks;


Count(*)
5
1 rows in set (0.02 sec)

mysql> select count(distinct city) from student;


count(distinct address)
4
1 rows in set (0.01 sec)

mysql> select min(Biology), max(Chemistry) from marks;


min(Biology) max(Chemistry)
45 83

1 rows in set (0.05 sec)

83
The Update Command

mysql> update marks set Total = Computer + Physics + Chemistry + Biology, Average=Total/4;
Query OK, 5 row affected (0.06 sec)
Row matched : 5 Changed : 5 Warnings : 0
mysql> select * from marks;
sid Computer Physics Chemistry Biology Total Average
101 89 67 58 90 304 76
102 78 98 65 45 286 72
103 56 78 83 97 314 79
104 99 48 69 75 291 73
105 87 82 79 60 308 77
5 rows in set (0.00 sec)

Delete Command

mysql>Delete from marks where total<300;


mysql>Select * from marks;

Drop Command

mysql>Drop table marks:

84

You might also like