Professional Documents
Culture Documents
from a shop.Item
is having itemid,description,price,qoh.
Shop is having a set of items for the customers.
OR
CREATE TABLE customer_master (
customerid VARCHAR(6) PRIMARY KEY,
firstname VARCHAR(10),
middlename VARCHAR(10),
lastname VARCHAR(10),
address VARCHAR(10),
);
SELECT customerid,firstname
FROM customer_master;
SELECT firstname,middlename,lastname
FROM customer_master;
SELECT lastname,middlename,firstname
FROM customer_master;
SELECT customerid,firstname
FROM customer_master
WHERE customerid='C00001';
--------------------------------------------------------------
RESTRICT (because we are filtering or restricting
the number of rows from the table ).
Examples
SELECT customerid,firstname,middlename,lastname
FROM customer_master
WHERE customerid='C00001';
Question3:-
Display customerid,firstname,middlename,lastname
and address from customer_master
where the customer's id is C00001 and C00002.
SELECT customerid,firstname,middlename,lastname,address
FROM customer_master
WHERE customerid='C00001' OR customerid='C00002';
OR
SELECT customerid,firstname,middlename,lastname,address
FROM customer_master
WHERE customerid IN ('C00001','C00002')
-------------------------------------------------------------
JOIN
Display customerid,firstname,date_of_purchase.
SELECT customer_master.customerid,firstname,date_of_purchase
FROM customer_master JOIN item_purchase
ON customer_master.customerid=item_purchase.customerid;
OR
SELECT item_purchase.customerid,firstname,date_of_purchase
FROM customer_master JOIN item_purchase
ON customer_master.customerid=item_purchase.customerid;
OR
SELECT item_purchase.customerid,firstname,date_of_purchase
FROM customer_master JOIN item_purchase
ON customer_master.customerid=item_purchase.customerid;
OR
SELECT ip.customerid,firstname,date_of_purchase
FROM customer_master cm JOIN item_purchase ip
ON cm.customerid=ip.customerid;