You are on page 1of 2

-- P:\data\Yeslam\ITC114\Chp3>

-- sqlite3.exe chp3prac.db
-- https://mivuletech.wordpress.com/2011/03/22/an-overview-of-relational-algebra-
operators-and-their-sql-translations/
-- https://www.youtube.com/watch?v=tDaB9swAPtM
-- http://www.w3resource.com/sql/joins/perform-an-equi-join.php

.headers on
.mode column
.separator ,

.output chp3pracout.txt

select * from PROFESSOR;


select * from STUDENT;
select * from booth;
select * from machine;

.print "______________________________________________"

-- Union
.print "This is Union"
select * from booth union select * from machine;
.print "______________________________________________"

-- Intersect
.print "This is intersect"
select booth_price from booth intersect select machine_price from machine;
.print "______________________________________________"

select booth_price, booth_product from booth intersect select machine_price,


machine_product from machine;
.print "______________________________________________"

-- Except (Minus)
.print "This is Except (Minus)"
select * from booth except select * from machine;
.print "______________________________________________"

-- Product
.print "This is Product"
select * from booth, machine;
.print "______________________________________________"

-- ------------------------
-- a natural join
.print "This is natural join"
select * from professor natural join student;
.print "______________________________________________"

select stu_code, prof_code from professor natural join student;


.print "______________________________________________"

--inner join
.print "This is inner join"
select * from student inner join professor on
student.prof_code=professor.prof_code;
.print "______________________________________________"
select stu_code from student inner join professor on student.prof_code=
professor.prof_code;
.print "______________________________________________"

-- equijoin
.print "This is equijoin"
select * from student join professor on student.prof_code=professor.prof_code;
.print "______________________________________________"

select * from student, professor where student.prof_code=professor.prof_code;


.print "______________________________________________"

-- where condition
select * from student, professor where student.prof_code=professor.prof_code;
.print "______________________________________________"

-- outer join
.print "This is outer join"
select * from student left join professor on student.prof_code=professor.prof_code;
.print "______________________________________________"

-- Left Join
select * from student left join professor on student.prof_code=professor.prof_code;
.print "______________________________________________"

You might also like