0% found this document useful (0 votes)
5 views

sample question

The document contains information about three database tables: 'student', 'course', and 'registration', detailing their structures and sample data. It also includes SQL queries to find students registered in specific courses, such as 'cse 1151' and 'cse 1153', as well as students living in 'Nirala'. The queries demonstrate various methods to join tables and filter results based on course titles and student addresses.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

sample question

The document contains information about three database tables: 'student', 'course', and 'registration', detailing their structures and sample data. It also includes SQL queries to find students registered in specific courses, such as 'cse 1151' and 'cse 1153', as well as students living in 'Nirala'. The queries demonstrate various methods to join tables and filter results based on course titles and student addresses.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Table name - student

sid( varchar(10)) sname( varchar(100)) Address(text)


010201 Ruben Nirala
010202 Faysal Gollamari
010203 Mashiyat Nirjon
010204 kamrul Nirala
Table name - course

cid( varchar(20)) ctitle (varchar(100)) credit (float)


cse 1151 Database systems 1.5
cse1153 Computer fundamentals 2
cse1155 Microsoft word & excel 3
Cse1157 Office essentials 2
Table name- registration

sid( varchar(20)) cid( varchar(20)) gpa(float)


010201 cse 1151 3.75
010202 cse 1151 3.5
010203 cse 1151 3.25
010201 cse 1153 3.5
010203 cse 1153 3.25
010201 cse 1155 3.75
010204 cse 1155 3.25
010204 cse1157 3.5
010203 cse 1157 3.25
010203 cse 1155 3.75

1. Find all those students who have registered the course ‘cse 1151’
Select *
from student s, registration r
where s.sid=r.sid and r.cid like "cse1151"
or
Select *
from student s, registration r
where s.sid=r.sid and r.cid = "cse1151"
or
Select *
from student s
inner join registration r
on s.sid=r.sid
where r.cid = "cse1151"

2. Find the names of all those students who have registered the course ‘1153’
Select s.sname, s.sid, r.cid
from student s, registration r
where s.sid=r.sid and r.cid like "cse1153"
or
Select s.sname, s.sid, r.cid
from student s, registration r
where s.sid=r.sid and r.cid ="cse1153"
or
Select s.sname, s.sid, r.cid
from student s
inner join registration r
on s.sid=r.sid
where r.cid ="cse1153"
3. Find the names and student ids of all those students who have registered the course titled ‘computer fundamentals’
Select s.sname, s.sid, c.cid, c.ctitle
from course c, registration r, student s
where
c.cid=r.cid
and r.sid=s.sid
and c.ctitle like"*computer fundamentals*"
or
Select s.sname, s.sid, c.cid, c.ctitle
from course c, registration r, student s
where
c.cid=r.cid
and r.sid=s.sid
and c.ctitle="computer fundamentals"
4. Find the names and student ids of all those students who have registered a course that has ‘puter’ in its title.
Select s.sname, s.sid, c.cid, c.ctitle
from course c, registration r, student s
where
c.cid=r.cid
and r.sid=s.sid
and c.ctitle like"*puter*"

5. Find the names, student ids, course titles and course ids of those students who live in ‘nirala’

Select s.sname, s.sid, c.cid, c.ctitle, s.address

from student s, registration r, course c

where

s.sid=r.sid
and r.cid=c.cid
and s.address like"*nirala*"

or

Select s.sname, s.sid, c.cid, c.ctitle, s.address

from student s, registration r, course c

where

s.sid=r.sid

and r.cid=c.cid

and s.address="nirala"

You might also like