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

SQL Operations for Student Records

programs

Uploaded by

sasi
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)
20 views3 pages

SQL Operations for Student Records

programs

Uploaded by

sasi
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

SQL RELATED PROGRAMS

1) Display record whose name start with particular character


import [Link]
mydb=[Link](host="localhost",user="root",database='result',
passwd="Sasi@2023",auth_plugin="mysql_native_password")
cursor=[Link]()
s='SELECT * FROM mark1 where STUD_NAME like "s%"'
print("MARK1 TABLE")
[Link](s)
print([Link]())
s1='SELECT * from mark1 where STUD_NAME like "_H%"'
print("MARK1 TABLE")
[Link](s1)
print([Link]())
__________________________________________________________________________________
2) update mark of particular student
import [Link]
mydb=[Link](host="localhost",user="root",database='result',
passwd="Sasi@2023",auth_plugin="mysql_native_password")
cursor=[Link]()
s='update mark1 set MARK=MARK+5 where STUD_NAME="SHALINI"'
[Link](s)
[Link]()
print("MARK1 TABLE")
s1='select * from mark1'
[Link](s1)
print([Link]())

3) inserting records into table


import [Link]
mydb=[Link](host="localhost",user="root",database='result',
passwd="Sasi@2023",auth_plugin="mysql_native_password")
cursor=[Link]()
sql='INSERT INTO mark1 values(12001,"SHYAM",98.23),
(12002,"ABISHEK",87.56),(12003,"SRI",90.67),(12004,"SHALINI",85.98),
(12005,"VISHAL",78.87)'
[Link](sql)
[Link]()
s='SELECT * FROM mark1'
print("MARK1 TABLE")
[Link](s)
print([Link]())
__________________________________________________________________________________
4) sorting records
import [Link]
mydb=[Link](host="localhost",user="root",database='result',
passwd="Sasi@2023",auth_plugin="mysql_native_password")
cursor=[Link]()
s='SELECT * FROM mark1 order by STUD_NAME'
print("MARK1 TABLE")
[Link](s)
print([Link]())
s1='SELECT * from mark1 order by MARK DESC'
print("MARK1 TABLE")
[Link](s1)
print([Link]())
__________________________________________________________________________________
5) display student record whose mark greater than 90
import [Link]
mydb=[Link](host="localhost",user="root",database='result',
passwd="Sasi@2023",auth_plugin="mysql_native_password")
cursor=[Link]()
s='SELECT * FROM mark1 where MARK>90'
print("MARK1 TABLE")
[Link](s)
print([Link]())
________________________________________________________________________________
6) display selected column
import [Link]
mydb=[Link](host="localhost",user="root",database='result',
passwd="Sasi@2023",auth_plugin="mysql_native_password")
cursor=[Link]()
s='SELECT REGNO,MARK FROM mark1'
print("MARK1 TABLE")
[Link](s)
print([Link]())
7) create database
import [Link]
mydb=[Link](host="localhost",user="root",passwd="Sasi@20
23",auth_plugin="mysql_native_password")
cursor=[Link]()
sql='create database result1'
[Link](sql)
s='show databases'
print("ALL DATABASES")
[Link](s)
print([Link]())

You might also like