0% found this document useful (0 votes)
15 views55 pages

CS Practical File 2024-25

The document is a practical record file for Computer Science students at DAV Public School, Hazaribag, for the AISSCE 2024-25. It includes an index of experiments with their titles, pages, dates, and signatures, covering various programming tasks in Python. Each experiment consists of an aim, program code, and output examples demonstrating the functionality of the code.

Uploaded by

shreyashbariar21
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)
15 views55 pages

CS Practical File 2024-25

The document is a practical record file for Computer Science students at DAV Public School, Hazaribag, for the AISSCE 2024-25. It includes an index of experiments with their titles, pages, dates, and signatures, covering various programming tasks in Python. Each experiment consists of an aim, program code, and output examples demonstrating the functionality of the code.

Uploaded by

shreyashbariar21
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/ 55

DAV PUBLIC SCHOOL , HAZARIBAG

COMPUTER SCIENCE
PRACTICAL RECORD FILE
AISSCE-2024-25

SUBMITTED BY:
NAME :………………………………...
Board Roll :….….………………………….

1|Page
CERTIFICATE
Certified that this is a bonafide computer science practical record work
done by Mr./Mis._________________during the year 2024- 2025
Submitted for the practical exam held on_________
at__________________________________

External Examiner Internal Examiner

2|Page
INDEX
EXP. TITLE OF EXPERIMENT PAGE DATE Signature
NO. NO.
1 HCF of two Numbers 4 18/04/2024
2 Factorial of a number 5 04/05/2024
3 Fibonacci Series to nth Term 6 13/05/2024
4 Sum of all elements in a list 7 17/06/2024
5 Occurrence of any word in a string 8 24/06/2024
6 Reading file line by line and printing 9 02/07/2024
7 Read Lines of a file and store it in a List 10 19/07/2024
8 Number of names in a Text File 11 22/07/2024
9 Frequency of words in a Text File 12 29/07/2024
10 Copying Text File Contents 13 04/08/2024
11 Display File size and File contents in Upper 15 08/08/2024
12 Store and search Details using Binary file 16 18/08/2024
13 Binary file Updating 18 23/08/2024
14 Store and Search details Using CSV file 20 26/08/2024
15 Simulating Dice using Random module 22 09/09/2024
16 Stack implementation 23 12/09/2024
17 Phishing - common word occurring 26 11/10/2024
18 Facebook using Dictionary 27 21/10/2024
19 Armstrong or Palindrome number 29 01/11/2024
20 Employee Details– Interfacing with MySQL 31 10/11/2024
21 MSQL Commands 36 17/11/2024

;
Experiment No: 1 HCF of two Numbers

3|Page
Aim :

Write an application program using python to find HCF of Two numbers using function concept

Program:

defhcf(x, y):
if x > y:
smaller = y
else:
smaller = x
for i in range(1,smaller + 1):
if((x % i == 0) and (y % i == 0)):
hcf = i
return hcf
# Main Block
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("The H.C.F. of", num1,"and", num2,"is", hcf(num1, num2))

Output :

Enter first number: 16


Enter second number: 4
The H.C.F. of 16 and 4 is 4

Experiment No: 2 Factorial of a number

4|Page
Aim :

Write an application program using python to Find the factorial of a number using function
concept

Program:

def factorial(n):
if n == 1:
return n
else:
f=1
for a in range(1,(n+1)):
f*=a
return f

# Main Block

num = int(input("Enter a number: "))


# check is the number is negative
ifnum< 0:
print("Sorry, factorial does not exist for negative numbers")
elifnum == 0:
print("The factorial of 0 is 1")
else:
print("The factorial of",num,"is",factorial(num))

Output:
Enter a number: 6
The factorial of 6 is 720

Experiment No: 3 Fibonacci Series to nth Term

5|Page
Aim :

Write an application program using python to print the fibonocci series till given nth term

Program:

deffibo(n):
if n <= 1:
return n
else:
f1=0
f2=1
f=f1+f2
FL=[f1,f2]
while n>0:
FL.append(f)
f1=f2
f2=f
f=f1+f2
n=n-1
return FL

#Main Block
nterms = int(input("Enter a number to limit the fibonocci series:"))
ifnterms<= 0:
print("Plese enter a positive integer")
else:
print("Fibonacci sequence:")
print(fibo(nterms-2))

Output:

Enter a number to limit the fibonocci series:15

Fibonacci sequence:
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]

Experiment No: 4 Sum of all elements in a list

Aim :

Write an application program using python to Find the sum of all elements of list

6|Page
Program:

defsum_arr(arr,size):
if (size == 0):
return 0
else:
sum=0
for a in arr:
sum+=a
return sum

# Main Block
n=int(input("Enter the number of elements for list:"))
a=[ ]
for i in range(0,n):
element=int(input("Enter element"+str(i+1)+":"))
a.append(element)
print("The list is:")
print(a)
print("Sum of items in list:",sum_arr(a,n))

Output:
Enter the number of elements for list:5
Enter element1:10
Enter element2:20
Enter element3:30
Enter element4:40
Enter element5:50
The list is:
[10, 20, 30, 40, 50]
Sum of items in list: 150

Experiment No: 5 Occurrence of any word in a string

7|Page
Aim :

Write an application program using python to find the Occurrence of any word in a string

Program:

defcountWord(str1,word):
s = str1.split()
count=0
for w in s:
if w==word:
count+=1
return count

str1 = input("Enter any sentence :")


word = input("Enter word to search in sentence :")
count = countWord(str1,word)
if count==0:
print("## Sorry! ",word," not present ")
else:
print("## ",word," occurs ",count," times ## ")

Output:

Enter any sentence :myindia, my kerala, my palakkad


Enter word to search in sentence :my
## my occurs 3 times ##

Experiment No:6 Reading file line by line and printing

8|Page
Aim :

Write an application program using python to Appending Lines to the file, reading that file line
by line and printing

Program:

L = ["God \n", "is \n", "Love\n"] # Creation of list with three lines

file1 = open('myfile.txt', 'w') # Opening a flie for writting


file1.writelines(L) #Appending a lines to the file
file1.close() # Closing the file

file1 = open('myfile.txt', 'r') # Opening a flie for reading


Lines = file1.readlines() # reading Lines from the file

count = 1
for line in Lines:
print("Line{}: {}".format(count, line.strip())) # Displaying Each Line of file using For Loop
count+=1

Output:

Line1: God
Line2: is
Line3: Love

Experiment No: 7 Read Lines of a file and store it in a List

9|Page
Aim :

Write an application program using python to

Program:

L = ["Python \n", "is a \n", "Programming Language \n"]

file1 = open('myfile.txt', 'w') # Opening a flie for writting


file1.writelines(L) #Appending a lines to the file
file1.close() # Closing the file

file1 = open('myfile.txt', 'r') # Opening a flie for reading


Lines = file1.readlines() # reading Lines from the file

count = 1
lst=[] # creating a list
for line in Lines:
print("Line{}: {}".format(count, line.strip())) # Displaying Each Line of file using For Loop
lst. append(line) # Storing each line in to a List
count+=1
print ("Lines in a file is stored in alist : ")
print(lst) #displaying the list

Output:

Line1: Python
Line2: is a
Line3: Programming Language
Lines in a file is stored in alist :
['Python \n', 'is a \n', 'Programming Language \n']

>>>

Experiment No: 8 Number of names in a Text File

10 | P a g e
Aim :

Write an application program using python to count the number of names in a text file (each
name stored in separate lines)

Program:

file1 = open('Newfile.txt', 'w')


num= int(input("Enter total number of names :"))# Opening a flie for writting
for i in range(num):
name=input("Enter name"+str(i+1)+":")
file1.writelines(name+"\n") #Appending a lines to the file
file1.close() # Closing the file

file1 = open('Newfile.txt', 'r') # Opening a flie for reading


Lines = file1.readlines() # reading Lines from the file
count=0
print ("Name File Contents\n************")
for a in Lines:
print(a)
count+=1 # counting
print ("Total Number of names in a file is : ",count )
file1.close()

Output:
Enter total number of names :4
Enter name1:John
Enter name2:Ram
Enter name3:Raheem
Enter name4:Suraj

File Contents
************
John
Ram
Raheem
Suraj

Total Number of names in a file is : 4

Experiment No: 9 Frequency of words in a Text File

11 | P a g e
Aim:

Write an application program using python, To count the number/ frequency of words in a
Text File

Program:

file1 = open('Newfile.txt', 'w')


num= int(input("Enter total number of lines :"))# Opening a flie for writting
for i in range(num):
line=input("Enter line"+str(i+1)+":")
file1.writelines(line+"\n") #Appending a lines to the file gddd
file1.close() # Closing the file

file1 = open('Newfile.txt', 'r') # Opening a flie for reading


words= file1.read().split() # reading Lines from the file
count=0
for word in words:
count+=1 # counting
print ("Total Number of words in a file is : ",count )
file1.close()

Output:

Enter total number of lines :3

Enter line1:hai
Enter line2:how are you
Enter line3:welcome back

Total Number of words in a file is : 6

Experiment No: 10 Copying Text File Contents

Aim:

12 | P a g e
Write an application program using python, to Copying contents of one text file and appending
into another text file

Program:

print("First file \n***********")


f = open('file1.txt', 'w')
num= int(input("Enter total number of Lines :"))# Opening a flie for writting
for i in range(num):
Line=input("Enter Line"+str(i+1)+":")
f.writelines(Line+"\n") #Appending a lines to the file
f.close() # Closing the file

print("Second file \n***********")


s = open('file2.txt', 'w')
num= int(input("Enter total number of Lines :"))# Opening a flie for writting
for i in range(num):
Line=input("Enter Line"+str(i+1)+":")
s.writelines(Line+"\n") #Appending a lines to the file
s.close()

f = open('file1.txt','r')
print ("\nContents in the First file ")
for word in f.read().split():
print(word, end=' ')
f.close()

s = open('file2.txt', 'r')
print ("\nContents in the Second File ")
for word in s.read().split():
print(word,end=' ')
s.close()

# Copying the file contents


f = open('file1.txt','r')
s = open('file2.txt', 'a')
for word in f.read().split():
s.write(word)
s.write("\n")
f.close()
s.close()

print ("\nContents in the Second File after copying from the First file: ")
s = open('file2.txt', 'r')
for word in s.read().split():
print(word,end=' ')
s.close()

13 | P a g e
Output

First file
***********
Enter total number of Lines :2
Enter Line1:hello
Enter Line2:welcome to SRCS
Second file
***********
Enter total number of Lines :3
Enter Line1:StRaphaels cathedral school
Enter Line2:Senior Secondary school
Enter Line3:CBSEaffliated,

Contents in the First file:


hello welcome to SRCS

Contents in the Second File:


St Raphaels cathedral school Senior Secondary school CBSE affliated,

Contents in the Second File after copying from the First file:
St Raphaels cathedral school Senior Secondary school CBSE affliated, hello welcome to SRCS

Experiment No: 11Display File size and File contents in Upper case

14 | P a g e
Aim:

Write an application program using python, to Display File size and File contents in Upper case

Program:

print("File Entry \n***********")


f = open('Newfile.txt', 'w')
num= int(input("Enter total number of Lines :"))# Opening a flie for writting
for i in range(num):
Line=input("Enter Line"+str(i+1)+":")
f.writelines(Line+"\n") #Appending a lines to the file
f.close() # Closing the file

deffile_size(fname): # function for finding the file size


import os
statinfo = os.stat(fname)
return (statinfo.st_size)-3

def Upper(fname): # converting the file contents to upper case


file1=open(fname,'r')
for word in file1.read().split():
print(word.upper(),end=' ')

print("File size in bytes of a plain file: ",file_size("Newfile.txt"))


print("File contents in upper case: ",end='')
Upper("Newfile.txt")

Output:

File Entry
***********
Enter total number of Lines :1
Enter Line1:My best school, SRCS
File size in bytes of a plain file: 19

File contents in upper case: MY BEST SCHOOL, SRCS

Experiment No: 12Store and search Details using Binary file

15 | P a g e
Aim:

Write an application program using python,to create binary file to store Rollno and Name,
Search any Rollno and display name if Rollno found otherwise “Rollno not found”

Program:

import pickle
student=[]
f=open('student.dat','wb')
ans='y'
while ans.lower()=='y':
roll = int(input("Enter Roll Number :"))
name = input("Enter Name :")
student.append([roll,name])
ans=input("Add More ?(Y)")
pickle.dump(student,f)
f.close()

f=open('student.dat','rb')
student=[]
while True:
try:
student = pickle.load(f)
except EOFError:
break

ans='y'
while ans.lower()=='y':
found=False
r = int(input("Enter Roll number to search :"))
for s in student:
if s[0]==r:
print("## Name is :",s[1], " ##")
found=True
break
if not found:
print("####Sorry! Roll number not found ####")
ans=input("Search more ?(Y) :")
f.close()

Output:

Enter Roll Number :1


Enter Name :John
Add More ?(Y)y

16 | P a g e
Enter Roll Number :2
Enter Name :Ram
Add More ?(Y)y
Enter Roll Number :3
Enter Name :Raheem
Add More ?(Y)n
Enter Roll number to search :3
## Name is :Raheem ##
Search more ?(Y) :y
Enter Roll number to search :4
####Sorry! Roll number not found ####
Search more ?(Y) :n

Experiment No: 13 Binary file Updating

17 | P a g e
Aim:

Write an application program using python, to create binary file to store Rollno, Name and
mark , let user to change the marks entered.

Program:

import pickle
student=[]
f=open('student.dat','wb')
ans='y'
while ans.lower()=='y':
roll = int(input("Enter Roll Number :"))
name = input("Enter Name :")
marks = int(input("Enter Marks :"))
student.append([roll,name,marks])
ans=input("Add More ?(Y)")
pickle.dump(student,f)
f.close()

f=open('student.dat','rb+')
student=[]
while True:
try:
student = pickle.load(f)
except EOFError :
break

ans='y'
while ans.lower()=='y':
found=False
r = int(input("Enter Roll number to update :"))
for s in student:
if s[0]==r:
print("## Name is :",s[1], " ##")
print("## Current Marks is :",s[2]," ##")
m = int(input("Enter new marks :"))
s[2]=m
print("## Record Updated ##")
found=True
break
if not found:
print("####Sorry! Roll number not found ####")
ans=input("Update more ?(Y) :")
f.close()

18 | P a g e
Output:

Enter Roll Number :1


Enter Name :John
Enter Marks :98
Add More ?(Y)y
Enter Roll Number :2
Enter Name :Ram
Enter Marks :97
Add More ?(Y)n
Enter Roll number to update :2
## Name is : Ram ##
## Current Marks is : 97 ##
Enter new marks :99
## Record Updated ##
Update more ?(Y) :n

Experiment No: 14 Store and Seaarch details Using CSV file

19 | P a g e
Aim:

Write an application program using python, to create CSV file and store
empno,name,salary and search any empno and display name,salary and if not
foundappropriate message.

Program:
Import csv
with open('myfile.csv',mode='a') as csvfile:
mywriter = csv.writer(csvfile,delimiter=',')
ans='y'
while ans.lower()=='y':
eno=int(input("Enter Employee Number "))
name=input("Enter Employee Name ")
salary=int(input("Enter Employee Salary :"))
mywriter.writerow([eno,name,salary])
print("## Data Saved... ##")
ans=input("Add More ?")

with open('myfile.csv',mode='r') as csvfile:


myreader = csv.reader(csvfile,delimiter=',')
ans='y'
while ans=='y':
found=False
e = int(input("Enter Employee Number to search :"))
for row in myreader:
if len(row)!=0:
if int(row[0])==e:
print("NAME :",row[1])
print("SALARY :",row[2])
found=True
break
if not found:
print(" EMPNO NOT FOUND")
ans = input("Search More ? (Y)")

Output:

Enter Employee Number 1


Enter Employee Name Aswathy
Enter Employee Salary :25000
## Data Saved... ##

20 | P a g e
Add More ?y
Enter Employee Number 2
Enter Employee Name Riyas
Enter Employee Salary :30000
## Data Saved... ##
Add More ?n
Enter Employee Number to search :2
NAME: Riyas
SALARY : 30000
Search More ? (Y) n

Experiment No: 15 Simulating Dice using Random module

21 | P a g e
Aim:

Write an application program using python, to generate random number 1-6, simulating a
dice

Program:
import random
import time
print("Press CTRL+C to stop the dice ")
play='y'
while play=='y':
try:
while True:
for i in range(10):
print(i)
n = random.randint(1,6)
print(n,end='')
time.sleep(.10)
except KeyboardInterrupt:
print("Your Number is :",n)
ans=input("Play More? (Y) :")
if ans.lower()!='y':
play='n'
break

Ourput: (for getting output press ctrl+c)


6Your Number is : 6
Play More? (Y) :y
0
1
2
3
4
5
6
7
8
9
3Your Number is : 3
Play More? (Y) :y

Experiment No: 16 Stack implementation

22 | P a g e
Aim:

Write an application program to implement Stack in Python using List

Program:

def isEmpty(S):
if len(S)==0:
return True
else:
return False

def Push(S,item):
S.append(item)
top=len(S)-1

def Pop(S):
if isEmpty(S):
return "Underflow"
else:
val = S.pop()
if len(S)==0:
top=None
else:
top=len(S)-1
return val

def Show(S):
if isEmpty(S):
print("Sorry No items in Stack ")
else:
t = len(S)-1
print("(Top)",end=' ')
while(t>=0):
print(S[t],"<==",end=' ')
t-=1
print()

# main begins here


S=[] #Stack
top=None
while True:
print("**** STACK DEMONSTRATION ******")
print("1. PUSH ")
print("2. POP")
print("3. SHOW STACK ")
print("0. EXIT")
ch = int(input("Enter your choice :"))
if ch==1:

23 | P a g e
val = int(input("Enter Item to Push :"))
Push(S,val)
elif ch==2:
val = Pop(S)
if val=="Underflow":
print("Stack is Empty")
else:
print("\nDeleted Item was :",val)
elifch==3:
Show(S)
elif ch==0:
print("Bye")
break

Output:

**** STACK DEMONSTRATION ******


1. PUSH
2. POP
3. SHOW STACK
0. EXIT
Enter your choice :1
Enter Item to Push :10

Enter your choice :4


(Top) 30 <== 20 <== 10 <==

**** STACK DEMONSTRATION ******


1. PUSH
2. POP
3. SHOW STACK
0. EXIT
Enter your choice :3
Top Item : 30

**** STACK DEMONSTRATION ******


1. PUSH
2. POP
3. SHOW STACK
0. EXIT
Enter your choice :2
Deleted Item was : 30

**** STACK DEMONSTRATION ******


1. PUSH
2. POP
3. SHOW STACK
0. EXIT

24 | P a g e
Enter your choice :0 Bye

25 | P a g e
Experiment No: 17 Phishing - common word occurring
Aim:

Write an application program totake 10 sample phishing email, and find the most common word
occurring using List

Program:

phishingemail=[
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
]
myd={}
for e in phishingemail:
x=e.split('@')
for w in x:
if w not in myd:
myd[w]=1
else:
myd[w]+=1
key_max = max(myd,key=myd.get)
print("Most Common Occurring word is :",key_max)
Output:

Most Common Occurring word is : mymoney.com

26 | P a g e
Experiment No: 18 Facebook using Dictionary

Aim:

Write an application program to create profile of users using dictionary, also let the users to
search, delete and update their profile like face book application

Program:

FB={}
n=int(input(" enter no of details to be need "))
for i in range(n):
print (" FB NO ", i+1)
id=int(input(" enter id "))
na=input(" enter the name ")
pl=input(" enter ur place ")
nk=input(" enter profile name ")
r=[na,pl,nk]
FB[id]=r

k=FB.keys()
while True:
c=input(" \n please enter: 'S' for search : 'D' for delete : 'U' for update : ")
if(c in 'Ss'):
se=input(" enter the searching name ")
for i in k:
x=FB[i]
if(x[0]==se):
print (" searching record is : NAME : ",x[0]," , PLACE : ", x[1] ,"
,PROFILE NAME : ", x[2])
elif(c in 'dD'):
x=int(input(" enter id "))
if (x in k):
print(" deleted record is ", FB[x])
del FB[x]
else:
print ("invalid id")
elif(c in 'Uu'):
x=int(input (" enter the id "))
if(x in k):
v=FB[x]
na=v[0]
upl=input(" enter place ")
unk=input(" enter profile name")
FB[x]=[na,upl,unk]
print(" updated record is " ,FB[x])
else:
print(" invalid id")
ch=input(" Do you want to continue y/n")
if(ch!='y'):

27 | P a g e
break

Output:

enter no of details to be need 1


FB NO 1
enter id 1
enter the name sree
enterur place pkd
enter profile name sri

please enter: 'S' for search : 'D' for delete : 'U' for update : s
enter the searching name sree
searching record is : NAME : sree , PLACE : pkd ,PROFILE NAME : sri
Do you want to continue y/ny

please enter: 'S' for search : 'D' for delete : 'U' for update : u
enter the id 1
enter place thr
enter profile namesreeja
updated record is ['sree', 'thr', 'sreeja']
Do you want to continue y/ny

please enter: 'S' for search : 'D' for delete : 'U' for update : d
enter id 2
invalid id
Do you want to continue y/n

28 | P a g e
Experiment No: 19 Armstrong or Palindrome number

Aim:

Write an application program to,Check whether a number is (i) palindrome (ii) Armstrong by
function with return multiple values

Program:

defcalc(n):
s=0
r=0
while n>0:
d=n%10
r=r*10 + d
s=s+d*d*d
n//=10
return s, r
#main

n=int(input(" enter a number "))


x,y=calc(n)
if(n==1):
print( " ARMSTRONG & PALINDROME ")
elif(n==x):
print( " ARMSTRONG ")
elif(y==n):
print(" PALINDROME ")
else:
print(" SORRY , Not a Palindrome or Not an Armstrong number")

Output:

enter a number 153


ARMSTRONG

enter a number 1
ARMSTRONG & PALINDROME

enter a number 12721

PALINDROME

29 | P a g e
Experiment No: 20.a Data Insertion – Python with MySQL

Aim:

Write an application program to interface python with SQL database for employees data
insertion.

Program:

import mysql.connector as m
def insertion():
try:
con=m.connect(host='localhost',user='root',password='123',database='sample')
if(con.is_connected()):
print('Successfully connected')
mycur=con.cursor()
empid=int(input("Enter Employee ID :"))
empname= input("Enter employee name :")
query="insert into employee values ({},'{}')".format(empid,empname)
mycur.execute(query)
con.commit()
print ("Record inserted successfully")
mycur.close();
con.close()
except Exception as e:
print(e)

#Main block

insertion()

Output
Successfully connected
Enter Employee ID : 101
Enter employee name :Arjun
Record inserted successfully

30 | P a g e
Experiment No: 20.b Data Deletion – Python with MySQL

Aim:

Write an application program to interface python with SQL database for employees data
deletion.

Program:
import mysql.connector as m
def deletion():
try:
con=m.connect(host='localhost',user='root',password='123',database='sample')
if(con.is_connected()):
print('successfully connected')
mycur=con.cursor()
empid=int(input("Enter Employee ID to be deleted :"))
query="delete from employee where empid={}".format(empid)
mycur.execute(query)
con.commit()
print ("Record deleted successfully")
mycur.close();
con.close()
except Exception as e:
print(e)

#Main Block

deletion()

Output
Successfully connected
Enter Employee ID to be deleted : 101

Record deleted successfully

31 | P a g e
Experiment No: 20.c Data Updating – Python with MySQL

Aim:

Write an application program to interface python with SQL database for employees data
updation.

Program:
import mysql.connector as m
def updation():
try:
con=m.connect(host='localhost',user='root',password='123',database='sample')
if(con.is_connected()):
print('successfully connected')
mycur=con.cursor()
empid=int(input("Enter Employee ID to be update :"))
empname= input("Enter new name of employee :")
query="update employee set name ='{}' where empid={}".format(empname,empid)
mycur.execute(query)
con.commit()
print ("Record updated successfully")
mycur.close();
con.close()
except Exception as e:
print(e)

#Main Block
updation()

Output:
Successfully connected
Enter Employee ID to be update : 101
Enter new name of employee :Arjun Ravi
Record updated successfully

Experiment No: 20.d Data Display – Python with MySQL

32 | P a g e
Aim:

Write an application program to interface python with SQL database for employees data
display.

Program:
import mysql.connector as m
def display():
try:
con=m.connect(host='localhost',user='root',password='123',database='sample')
if(con.is_connected()):
print('successfully connected')
mycur=con.cursor()
query="Select * from Employee"
mycur.execute(query)
myrows=mycur.fetchall()
print ("Records in Employee table are:")
for row in myrows:
print(row)
print("all rows printed successfully!")
mycur.close();
con.close()
except Exception as e:
print(e)

#Main block
display()

Output:
successfully connected
Records in Employee table are:
[101,’Anu’]
[102,’Minnu’]
[103,’Jinu’]
all rows printed successfully!

Experiment No: 20.e Data Search – Python with MySQL

33 | P a g e
Aim:

Write an application program to interface python with SQL database for employees data
searching by applying a condition (maximum salary of a teacher).

Program:

import mysql.connector as m
def display():
try:
con=m.connect(host='localhost',user='root',password='123',database='sample')
if(con.is_connected()):
print('successfully connected')
mycur=con.cursor()
query="Select max(sal) from salary; "
mycur.execute(query)
myrow=mycur.fetchall()
print ("Maximum salary of teacher :")
print(myrow)
mycur.close();
con.close()
except Exception as e:
print(e)

#Main block

display()

Output:
successfully connected
Maximum salary of teacher : 59000

34 | P a g e
Experiment NO: 21 MY SQL

1. CREATE DATABASE
AIM
Create a Database of name EMPLOYEE.

QUERY

 CREATE DATABASE EMPLOYEE;

2. OPEN COMMAND
AIM
Open the Database using the USE command.
QUERY
 USE DATA

3. CREATE TABLE
AIM
Create table EMP with specified number of rows and columns and apply necessary constraints.
QUERY
 CREATE TABLE EMP
(ENO INTEGER PRIMARYKEY, ENAME VARCHAR (20) UNIQUE,
JOB VARCHAR (20) DEFAULT “CLERK”, GENDER CHAR (1) NOT
NULL, HIRE DATE, SAL FLOAT (6,2) CHECK SAL>2000,COMM INTEGER);

4. INSERT COMMAND
AIM
Insert tuples to the table EMP.

QUERY
 INSERT INTO EMP VALUES(1,’KING’,’MANAGER’,’M’,’1981-11-17’,5000,NULL);
 INSERT INTO EMP VALUES(2,’BLAKE’,’MANAGER’,’M’,’1981-05-01’,2850,NULL);

35 | P a g e
 INSERT INTO EMP VALUES(3,’JASMIN’,’SALESMAN’,’F’,’1982-12-09’,2450,300);
 INSERT INTO EMP VALUES(4,’JONES’,’SALESMAN’,’M’,’1983-01-12’,2975,500);
 INSERT INTO EMP VALUES(5,’CLARK’,’ANALYST’,’M’,’1983-01-23’,1250,NULL);
 INSERT INTO EMP VALUES(6,’GEETHA’,’CLERK’,’F’,’1981-02-22’,1600,NULL);

5. SELECT COMMAND
AIM
Display all employee details.
QUERY
 SELECT * FROM EMP;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
6 GEETHA CLERK F 1981-02-22 1600.00 NULL

AIM
Display ENO, ENAME and JOB of all Employees.
QUERY
 SELECT ENO,ENAME,JOB FROM EMP;

OUTPUT

ENO ENAME JOB


1 KING MANAGER
2 BLAKE MANAGER
3 JASMIN SALESMAN
4 JONES SALESMAN
5 CLARK ANALYST
6 GEETHA CLERK
6. USING DISTINCT KEYWORD
AIM

36 | P a g e
Display job of employee by eliminating redundant data.
QUERY
 SELECT DISTINCT JOB FROM EMP;
OUTPUT

DISTINCT JOB
MANAGER
SALESMAN
ANALYST
CLERK

7. USING WHERE CLAUSE


AIM
Display all details of employee who is having job as salesman.
QUERY
 SELESCT * FROM EMP WHERE JOB=’SALESMAN’;

OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500
8. RELATIONAL OPERATOR
AIM
Display the details of employee whose name is not ‘KING’.

QUERY
 SELECT * FROM EMP WHERE ENAME<>’KING’;

OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500

37 | P a g e
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
AIM
Display the details of employee ENO,ENAME,SAL of people whose salary is above 2500.
QUERY
 SELECT ENO,ENAME,SAL FROM EMP WHERE SAL>2500;
OUTPUT

ENO ENAME SAL


1 KING 5000.00
2 BLAKE 2850.00
4 JONES 2975.00
9. LOGICAL OPERATORS
AIM
Display the details of employee whose job is manager or gender is male.

QUERY
 SELECT * FROM EMP WHERE JOB=’MANAGER’ OR GENDER=’M’;

OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
4 JONES SALESMAN M 1983-01-12 2975.00 500
5 CLARK ANALYST M 1983-01-23 1250.00 NULL

AIM
Display the ENO, ENAME and COMM of employees with commission.

QUERY
 SELECT ENO,ENAME,COMM FROM EMP WHERE COMM IS NOT NULL;

OUTPUT

38 | P a g e
ENO ENAME SAL JOB
3 JASMIN 2450.00 SALESMAN
4 JONES 2975.00 SALESMAN

AIM
Display the details of employees whose job is not salesman.
QUERY
 SELECT * FROM EMP WHERE JOB NOT=’SALESMAN’;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
6 GEETHA CLERK F 1981-02-22 1600.00 NULL

10. USING BETWEEN- AND CLAUSE


AIM
Display the details of employees whose salary is between 2000 and 5000.
QUERY
 SELECT * FROM EMP WHERE SAL BETWEEN 2000 AND 5000;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500

AIM
Display the details of employees whose salary is not between 2000 and 5000.
QUERY
 SELECT * FROM EMP WHERE SAL NOT BETWEEN 2000 AND 5000;

39 | P a g e
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


5 CLARK ANALYST M 1983-01-23 1250.00 NULL
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
11. CONDITION BASED ON A LIST
AIM
Display the details of employees having job as manager, salesman and clerk.

QUERY
 SELECT * FROM EMP WHERE JOB IN(‘MANAGER’,’SALESMAN’,’CLERK’);
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500
6 GEETHA CLERK F 1981-02-22 1600.00 NULL

AIM
To display the details of employees except people having job as Salesman, Manager and Clerk.
QUERY
 SELECT * FROM EMP WHERE JOB NOT IN(‘MANAGER’,’SALESMAN’,’CLERK’);
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


5 CLARK ANALYST M 1983-01-23 1250.00 NULL
12. CONDITION BASED ON A PATTERN MATCH
AIM
Display the details of Employee whose ENAME starts with ‘J’;
QUERY
 SELECT * FROM EMP WHERE ENAME LIKE ‘J%’;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM

40 | P a g e
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500
AIM
Display the details of Employees whose ENAME ends with ‘S’;
QUERY
 SELECT * FROM EMP WHERE ENAME LIKE ‘%S’;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


4 JONES SALESMAN M 1983-01-12 2975.00 500

AIM
Display the details of Employee whose job contains “AL” string.

QUERY
 SELECT * FROM EMP WHERE JOB LIKE “%AL%”;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
AIM
To display the details of Employees whose ENAME contains exactly 5 letters.
QUERY
 SELECT * FROM EMP WHERE ENAME LIKE “-----“;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
4 JONES SALESMAN M 1983-01-12 2975.00 500
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
AIM
To display the details of Employees whose ENAME contains at least 6 characters.

41 | P a g e
QUERY
 SELECT * FROM EMP WHOSE ENAME LIKE “------%”;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


3 JASMIN SALESMAN F 1982-12-09 2450.00 300
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
13. SEARCH FOR NULL
AIM
Display ENO,ENAME,COMM from Employee who doesn’t have commission.

QUERY
 SELECT ENO,ENAME,COMM FROM EMP WHERE COMM IS NULL;
OUTPUT

ENO ENAME COMM


1 KING NULL
2 BLAKE NULL
5 CLARK NULL

AIM
Display the ENO,ENAME and COMM of employees with commission.
QUERY
 SELECT ENO,ENAME,COMM FROM EMP WHERE COMM IS NOT NULL;
OUTPUT

ENO ENAME COMM


3 JASMIN 300
4 JONES 500
14. SORTING RESULTS BY ORDER BY
AIM
Display the details of Employees according to the alphabetical order of their ENAME;
QUERY
 SELECT * FROM EMP ORDER BY ENAME ASC;

42 | P a g e
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
4 JONES SALESMAN M 1983-01-12 2975.00 500
1 KING MANAGER M 1981-11-17 5000.00 NULL
AIM
Display the details of Employee by descending order of ENAME.

QUERY
 SELECT * FROM EMP ORDER BY ENAME DESC;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
4 JONES SALESMAN M 1983-01-12 2975.00 500
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
AIM
Display the details of Employee by descending order of ENAME and SAL in ascending order.
QUERY
 SELECT * FROM EMP ORDER BY ENAME DESC, SAL ASC;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM


1 KING MANAGER M 1981-11-17 5000.00 NULL
4 JONES SALESMAN M 1983-01-12 2975.00 500
3 JASMIN SALESMAN F 1982-12-09 2450.00 300
6 GEETHA CLERK F 1981-02-22 1600.00 NULL
5 CLARK ANALYST M 1983-01-23 1250.00 NULL
2 BLAKE MANAGER M 1981-05-01 2850.00 NULL
15. SIMPLE CALCULATIONS
AIM
Perform simple calculations.

43 | P a g e
QUERY
 SELECT 5*6 FROM DUAL;
OUTPUT

5*6
30

16. DATE FUNCTIONS


AIM
Display the date with time.
QUERY
 SELECT SYSDATE() FROM DUAL;
OUTPUT

SYSDATE()
2015-07-19 11:45:30

AIM
Display the current system date.
QUERY
 SELECT CURDATE();
OUTPUT

CURDATE()

AIM
Display current date and time.
QUERY
 SELECT NOW();
OUTPUT

NOW()

44 | P a g e
AGGREGATE FUNCTIONS
17. SUM FUNCTIONS
AIM
Display the sum of salary of employees having job as Manager.

QUERY
 SELECT SUM(SAL) FROM EMP WHERE JOB=’MANAGER’;
OUTPUT

SUM(SAL)
7850.00

18. GROUP BY
AIM
Display the total salary of Employees in each Department

QUERY
 SELECT JOB<SUM(SAL) FROM EMP GROUP BY JOB;

OUTPUT
JOB SUM(SAL)
ANALYST 1250.00
CLERK 1600.00
MANAGER 7850.00
SALESMAN 5245.00

AIM
Display the total Salary of Female.

QUERY
 SELECT GENDER<SUM(SAL) FROM EMP GROUP BY GENDER

45 | P a g e
GENDER SUM(SAL)
F 4050.00
M 12075.00

19.USING HAVE CLAUSE


AIM
Display the sum of salary in each job whose number of employees more than 2.

QUERY
 SELECT JOB<SUM(SAL) FROM EMP GROUP BY JOB HAVING COUNT(*)>=2;

OUTPUT
JOB SUM(SAL)
MANAGER 7850.00
SALESMAN 5425.00

AIM
Display Eno,Ename,Job and increase salary by 1000 whose job is Salesman.

QUERY
 SELECT ENO,ENAME,JOB,SAL+1000 FROM EMP WHERE JOB=’SALESMAN’;

OUTPUT
ENO ENAME JOB SAL+1000
3 JASMIN SALESMAN 3450.00
4 JONES SALESMAN 3975.00

20.PUTTING TEXT IN QUERY


AIM
Display Eno,Ename,Job, modify Salary into Sal*100 and add a column’$’ in the Employee table;

QUERY
 SELECT ENO.ENAME,JOB,SAL*100,”$” FROM EMP;

46 | P a g e
OUTPUT
ENO ENAME JOB SAL*100 $
1 KING MANAGER 500000 $
2 BLAKE MANAGER 285000 $
3 JASMIN SALESMAN 245000 $
4 JONES SALESMAN 297500 $
5 CLARK ANALYST 125000 $
6 GEETHA CLER 160000 $

21.CREATING TABLE FROM EXISTING TABLE


AIM
Create a Salary Table from the base table(Employee).

QUERY
 CREATE TABLE SALARY1 AS(SELECT ENO,ENAME,SAL FROM EMP WHERE
COMM IS NULL);
 SELECT * FROM SALARY1;

OUTPUT
ENO ENAME SAL
1 KING 5000
2 BLAKE 2850
5 CLARK 1250
6 GEETHA 1600

22.UPDATE COMMAND
AIM
Update the salary of an employee from EMP table.

QUERY
 UPDATE EMP SET SAL=2000 WHERE ENO=2;
 SELECT * FROM EMP;

OUTPUT
ENO ENAME JOB GENDER HIRE SAL COMM
1 KING MANAGER M 1981-11-17 5000 NULL
2 BLAKE MANAGER M 1981-03-01 2850 NULL
3 JASMIN SALESMAN F 1982-12-09 2450 300
47 | P a g e
4 JONES SALESMAN M 1983-01-12 2975 300
5 CLARK ANALYST M 1983-01-23 1250 NULL
6 GEETHA CLERK F 1981-02-22 1600 NULL

AIM
Display the table Salary1 after Updating the Salary as 2000 whoseEno is 2.

QUERY
 UPDATE SALARY1 SET SAL=2000 WHERE ENO=2;
 SELECT * FROM SALARY1;

OUTPUT
ENO ENAME SAL
1 KING 5000
2 BLAKE 2000
5 CLARK 1250
6 GEETHA 1600

AIM
Update the salary as 200 and Comm as 200 whoseEno is 1 and Display it.

QUERY
 UPDATE EMP SET VAL=2000,COMM=200 WHERE ENO=1;
 SELECT * FROM EMP;

OUTPUT
ENO ENAME JOB GENDER HIRE SAL COMM
1 KING MANAGER M 1981-11-17 5000 200
2 BLAKE MANAGER M 1981-03-01 2000 NULL
3 JASMIN SALESMAN F 1982-12-09 2450 300
4 JONES SALESMAN M 1983-01-12 2975 300
5 CLARK ANALYST M 1983-01-23 1250 NULL
6 GEETHA CLERK F 1981-02-22 1600 NULL

23.USING EXPRESSIONS IN UPDATE


AIM
Update the salary with current Salary+1000 whose job is Salesman and displat it.

48 | P a g e
QUERY
 UPDATE EMP SET SAL=SAL+1000 WHERE JOB=’SALESMAN’;
 SELECT * EMP;

OUTPUT
ENO ENAME JOB GENDER HIRE SAL COMM
1 KING MANAGER M 1981-11-17 2000 200
2 BLAKE MANAGER M 1981-03-01 2000 NULL
3 JASMIN SALESMAN F 1982-12-09 3450 300
4 JONES SALESMAN M 1983-01-12 3975 300
5 CLARK ANALYST M 1983-01-23 1250 NULL
6 GEETHA CLERK F 1981-02-22 1600 NULL

24.UPDATING TO NULL VALUES


AIM
Update the Salary of an employee having job as Clerk to null.

QUERY
 UPDATE EMP SET SAL=NULL WHERE JOB=’CLERK’;
 SELECT * FROM EMP;

OUTPUT
ENO ENAME JOB GENDER HIRE SAL COMM
1 KING MANAGER M 1981-11-17 2000 200
2 BLAKE MANAGER M 1981-03-01 2000 NULL
3 JASMIN SALESMAN F 1982-12-09 3450 300
4 JONES SALESMAN M 1983-01-12 3975 300
5 CLARK ANALYST M 1983-01-23 1250 NULL
6 GEETHA CLERK F 1981-02-22 NULL NULL

25.DELETE COMMAND
AIM
Remove the details of Employee whose Salary is above 3000 and Display it.

49 | P a g e
QUERY
 DELET FROM SALARY1 WHERE SAL>3000;
 SELECT * FROM SALARY1;

OUTPUT
ENO ENAME JOB GENDER HIRE SAL COMM
2 BLAKE MANAGER M 1981-03-01 2000 NULL
5 CLARK ANALYST M 1983-01-23 1250 NULL
6 GEETHA CLERK F 1981-02-22 NULL NULL

26.VIEW COMMAND
AIM
Create a table COMM1 containing EMPNO,EMPNAME,EJOB,SALARY,HIRE,GEN,COMM and
COMM is NULL and display it.

QUERY
 CREATE VIEW COMM1(EMPNO,EMPNAME,EJOB,GEN,HIRE,SALARY,COM)
AS SELECT * FROM EMP WHERE COMM IS NULL;
 SELECT * FROM COMM1;

OUTPUT
ENO ENAME JOB GENDER HIRE SAL COMM
2 BLAKE MANAGER M 1981-03-01 2000 NULL
5 CLARK ANALYST M 1983-01-23 1250 NULL
6 GEETHA CLERK F 1981-02-22 NULL NULL

AIM
Create the sample to display the detail of employee like EMPNO,EMPNAME,SALARY and whose
COMM is NULL and Display it.

QUERY

 CREATE VIEW SAMPLE(EMPNO,EMPNAME,SAL) AS SELECT


ENO,ENAME,SAL+100 FROM EMP WHERE COMM IS NULL;
OUTPUT

50 | P a g e
ENO ENAME SAL
2 BLAKE 2000
5 CLARK 1250
6 GEETHA NULL

27.BUILT-IN FUNCTIONS
AIM
Convert the given string into Lower Case.

QUERY

 SELECT LOWER(“HELLO”) FROM DUAL;

OUTPUT
LOWER(“HELLO”)
Hello

AIM
Convert the given string into Upper case.

QUERY

 SELECT UPPER(“hello”) FROM DUAL;

OUTPUT
LOWER(“HELLO”)
HELLO

AIM
Display the sub string of the given string.

QUERY

51 | P a g e
 SELECT SUBSTR(“POINTER”,3,2) FROM DUAL;

OUTPUT

SUBSTR(“POINTER”,3,2)

IN

28.DDL COMMANDS
ALTER COMMAND

AIM
Remove column Salary from salary table and display the table

QUERY
 ALTER TABLE SALARY1 DROP COLUMN SAL;
 SELECT * FROM SALARY1;

OUTPUT
ENO ENAME
2 BLAKE
5 CLARK
6 GEETHA

AIM
Add a new Column AGE to Employee table and Display it.

QUERY
 ALTER TABLE EMP ADD(AGE INT(2));
 SELECT * FROM EMP;
OUTPUT

ENO ENAME JOB GENDER HIRE SAL COMM AGE


1 KING MANAGER M 1981-11-17 2000 200 NULL
2 BLAKE MANAGER M 1981-03-01 2000 NULL NULL
3 JASMIN SALESMAN F 1982-12-09 3450 300 NULL
4 JONES SALESMAN M 1983-01-12 3975 300 NULL
5 CLARK ANALYST M 1983-01-23 1250 NULL NULL

52 | P a g e
6 GEETHA CLERK F 1981-02-22 NULL NULL NULL

AIM
Modify the size of the column ENAME into CHAR(25) using ALTER command and display the table
structure.

QUERY
 ALTER TABLE EMP MODIFY ENAME CHAR(25);
 DESCRIBE EMP;

OUTPUT
FIELD TYPE NULL KEY DEFAULT EXTRA
ENO int(11) NO PRI NULL
ENAME char(25) YES UNI NULL
JOB varchar(25) YES CLERK
GENDER char(1) NO NULL
HIRE date YES NULL
SAL float(6,2) YES NULL
COMM int(11) YES NULL
AGE int(2) YES NULL

AIM
Add Pri03y key constraints to the column ENO in the SALARY1 table and Describe it.

QUERY
 ALTER TABLE SALARY1 ADD PRI03Y KEY(ENO);
 DESCRIBE SALARY1;

OUTPUT
ENO Int(11) NO PRI NULL
ENAME Varchar(20) YES NULL

JOINS
AIM

Display Cid,Ename,Pid,Pname,Manufac From client and Product table whose having matching PID.

53 | P a g e
QUERY

 SELECT CID,ENAME,CLIENT.PID,PNAME,MANUFAC
 FROM CLIENT,PRODUCT
 WHERE CLIENT PID=PRODUCT.PID;

OUTPUT

CID ENAME PID PNAME MANUFAC

16 DREAMS TP01 TALCOM POWDER LAK

1 COSMETIC SHOP FW05 FACE WASH ABC

6 TOTAL HEALTH BS01 BATH SOAP ABC

12 LIVE LIFE SH06 SHAMPOO XYZ

15 PRETTY WOMAN FW12 FACE WASH XYZ

NATURAL JOIN

AIM

Display the Details of CLIENT and PRODCUT by using Natural Join.

QUERY

 SELECT *
 FROM CLIENT
 NATURAL JOIN PRODUCT;

OUTPUT

PID CID ENAME CITY PNAME MANUFAC PRICE

TP01 16 DREAMS BANGALORE TALCOM POWDER LAK 40

FW05 1 COSMETIC SHOP DELHI FACE WASH ABC 45

BS01 6 TOTAL HEALTH MUMBAI BATH SOAP ABC 55

SH06 12 LIVE LIFE DELHI SHAMPOO XYZ 120

54 | P a g e
FW12 15 PRETTY WOMAN DELHI FACE WASH XYZ 95

55 | P a g e

You might also like