St. Xavier'S College: (Affiliated To Tribhuvan University) Maitighar, Kathmandu
St. Xavier'S College: (Affiliated To Tribhuvan University) Maitighar, Kathmandu
XAVIER’S COLLEGE
(Affiliated to Tribhuvan University)
Maitighar, Kathmandu
Submitted By
Nilima Nayak
2nd Year/4th Sem
017BSCIT027
Submitted To
Signature Remarks
THEORY:
JOIN OPERATATION
The SQL joins clause is used to combine records from two or more tables in a database. A
JOIN is a means for combining fields from two tables by using values common to each.
Several operators can be used to join tables, such as =, <, >, < >, >=, <=, !=, BETWEEN,
LIKE, and NOT; they can all be used to join tables. However, the most common operator is
the equal to symbol.
There are different types of joins available in SQL −
1. Find the product name and product vendor information for orders
made by customer number 103.
CREATE DATABASE lab4;
USE lab4;
SHOW TABLES;
SELECT DATABASE();
3. Find the customer name and credit limit of the customers who made
orders with order numbers in 10128, 10130, 10136, 10137.
SELECT c.customerName, c.creditLimit
FROM customers c, orders o
WHERE c.customerNumber = o.customerNumber
AND o.orderNumber = 10128 OR 10130 OR 10136 OR 10137;
5. List all the product details for the orders made by Diego Freyre
( contactFirstName contactLastName).
SELECT p.*
FROM products p, orders o, orderdetails od, customers c
WHERE c.customerNumber=o.customerNumber AND
o.orderNumber=od.orderNumber AND od.productCode=p.productCode
AND c.contactFirstName = "Diego" AND c.contactLastName = "Freyre";
8. Find the product name and productline that are contained in order
number 10100.
SELECT productName, productLine from products
where productCode in (Select productCode from orderdetails where
orderNumber = 10100);