Dbms Lab Assignments-6
Dbms Lab Assignments-6
JOINING
DESCRIPTION
SQL JOINS are used to retrieve data from multiple tables. A SQL JOIN is performed whenever two or more
tables are joined in a SQL statement.
It is the most common type of SQL join. SQL INNER JOINS return all rows from multiple tables where the join
condition is met.
Visual Illustration
In this visual diagram, the SQL INNER JOIN returns the shaded area:
The SQL INNER JOIN would return the records where table1 and table2 intersect.
1) Create a table called suppliers with two fields’ supplier_id and supplier_name and insert the following
data:
title_id varchar(20)
title varchar(80)
type char(12)
pub_id char(4)
price integer
advance integer
royalty integer
notes varchar(200)
pubdate datetime
'1', 'Joe', 'Abra', '111 111-1111', '6 St.', 'Berkeley', 'CA', '11111', 1
'2', 'Jack', 'Majo', '222 222-2222', '3 St.', 'Oakland' , 'CA', '22222', 1
'3', 'Pink', 'Cherry', '333 333-3333', '5 Ln.', 'Vancouver', 'BC', '33333', 1
'4', 'Blue', 'Albert', '444 444-4444', '7 Av.', 'Vancouver', 'BC', '44444', 1
'5', 'Red', 'Anne', '555 555-5555', '6 Av.', 'Regina', 'SK', '55555', 1
8) Select au_lname, titlefrom authors and titles table using Join.
9) Select pub_id, price, contract fromauthors and titles table using Join.
10) Select title_id, type, au_lnamefrom authors and titles table where typebelongs topsychology.
11) Select title_id, title, au_lname,royaltyfrom authors and titles table whereroyaltybetween 10 to 14.
12) Select title, city, royaltyfrom authors and titles table wherepub_idbelongs to0877androyaltybelongs
to12.
13) Select au_id ,au_lname, title, pricefrom authors and titles table wherestatebelongs toCA Order By
address .