Professional Documents
Culture Documents
Practical Recording.
2. Create the table “customers”as table given below in the database “Marketers”.
CREATE TABLE Customers(
Customer_ID int PRIMARY KEY,
Last_name VARCHAR(20),
First_name VARCHAR(20),
Favourite_Website VARCHAR(70) NULL
);
Page 1 of 9
SEU/IS/18/ICT/005
3. Find all the records in the customers table in the customers table where the customer’s
last_name begins with ‘J’.
SELECT *FROM Customers
WHERE Last_name LIKE"J%";
4. Find all last_name values from the customers table where the last_name contains the
letter ‘S’.
SELECT *FROM Customers
WHERE Last_name LIKE"%S%";
Page 2 of 9
SEU/IS/18/ICT/005
5. Find all first_name values from the customers table where the first_name ends with
the letter ‘e’.
SELECT first_name FROM customers
WHERE first_name LIKE "%E";
6. Find all the records from the customers table where the last_name is 7 –cbaracter long
and ends with ‘n’.
SELECT * FROM Customers
WHERE last_name LIKE "_______N";
7. Find all of the records in the customers table where the ‘s’ first_name do not contain
‘e’.
SELECT * FROM Customers
WHERE first_name NOT LIKE "%E%";
Page 3 of 9
SEU/IS/18/ICT/005
Exercise 02.
1. In the database “ABC Marketers” ,create table “suppliers” based on the following
table.
CREATE TABLE Suppliers(
Supplier_id INT PRIMARY KEY,
Supplier_name VARCHAR(90),
City VARCHAR(20),
State VARCHAR(20),
turn_over INT
);
Page 4 of 9
SEU/IS/18/ICT/005
2. Retrieve all the records of the suppliers who are either from Georgia or Texas. (IN)
SELECT * FROM suppliers
WHERE state IN("Georgia","Texas");
3. Retrieve all the records of the suppliers who are not from California (NOT IN).
SELECT * FROM suppliers
WHERE state NOT IN("California");
4. Display the names of the suppliers with their supplier_id who has a turn over between
40000000 AND 70000000.
SELECT supplier_id, supplier_name FROM suppliers
WHERE turn_over BETWEEN 40000000 AND 70000000;
Page 5 of 9
SEU/IS/18/ICT/005
5. Display the names and city of the suppliers whose turnover is NOT BETWEEN
20000000 and 60000000.
SELECT Supplier_name , city FROM suppliers
WHERE turn_over NOT BETWEEN 20000000 AND 60000000;
6. Retrieve the suppliers name with their id, whose name of the city begins with R OR
from the state Arkansas.
SELECT supplier_name, supplier_id FROM suppliers
WHERE city LIKE "R%"OR state="Arkansas";
7. In the above database, create the table products based on the following table.
CREATE TABLE Products(
product_ID INT,
product_name VARCHAR(60),
supplier_id INT,
FOREIGN KEY (supplier_id) REFERENCES suppliers(supplier_ID),
unit_price INT
);
Page 6 of 9
SEU/IS/18/ICT/005
Page 7 of 9
SEU/IS/18/ICT/005
8. Retrieve the names and IDs of the supliers whose product having a unit price greater
than 1500. (some or any)
SELECT supplier_name supplier_id
FROM suppliers WHERE supplier_id =SOME
(SELECT supplier_id FROM products WHERE unit_price > 1500);
9. Display the names, city and IDs of the suppliers who has not supplied any product so
far.(ALL)
Page 8 of 9
SEU/IS/18/ICT/005
10. Find the output of the following code snippet_id, FROM products WHERE EXISTS
(SELECT supplier_id FROM suppliers);
Discussion:
Studied about how to use LIKE conditions for pattern matching.
Learn about how to apply suitable operators in queries.
Page 9 of 9