Databaselab 5

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Student Name: Amrit Kafle

Student ID: s4581578

Tutorial 5
(To be submitted Tuesday Week6)

Given the following tables (in 3NF):

itemColor (item(FK), color)

item (item, price(FK))

tax (price, tax)

Write SQL queries for the following questions:

1. List item, price and color of all items, whose price is 25.

select itemcolor.item, itemcolor.color, item.price from itemcolor inner join item


on item.item = itemcolor.item where price = 25;

2. List all items name, color, price and tax whose name is “polo”:

select itemcolor.item, itemcolor.color, tax.price, tax.tax from itemcolor join


item on itemcolor.item = item.item join tax on item.price = tax.price where
itemcolor.item = "polo";
3. List all item names “T-shirt” and “sweatshirt”, whose color is “blue” and
“black”:

select itemcolor.item, itemcolor.color from itemcolor where (item like 'T-shirt'


or item like 'sweatshirt') and (color like 'blue' or color like 'black')

4. List all item names, price and their tax:

select item.item, tax.price, tax.tax from tax inner join item on tax.price =
item.price

You might also like