0% found this document useful (0 votes)
12 views4 pages

Lab 5 Report

This lab report focuses on SQL wildcards and operators, detailing tasks involving the creation and querying of 'Customers' and 'Products' tables. It includes SQL statements for selecting data based on various conditions such as country, contact names, and price ranges. The report is submitted by Muhammad Rehan Umar to Sir Shahid Bhutta as part of the Database and Management System course at the University of Engineering and Technology, Taxila.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Lab 5 Report

This lab report focuses on SQL wildcards and operators, detailing tasks involving the creation and querying of 'Customers' and 'Products' tables. It includes SQL statements for selecting data based on various conditions such as country, contact names, and price ranges. The report is submitted by Muhammad Rehan Umar to Sir Shahid Bhutta as part of the Database and Management System course at the University of Engineering and Technology, Taxila.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION


ENGINEERING

COMPUTER ENGINEERING DEPARTMENT

DATABASE AND MANAGEMENT SYSTEM

LAB REPORT 05

Topic : SQL Wildcards & Operators

Submitted BY: MUHAMMAD REHAN UMAR

Submitted TO: SIR SHAHID BHUTTA

Roll No : (22-CP-72)
Semester : 6th

Section : OMEGA
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION
ENGINEERING

COMPUTER ENGINEERING DEPARTMENT

Lab Objective:
To understand SQL wild cards and the operators used in SQL.

Lab Tasks:

1: Consider the following table “Customers”:

Create the above table and do the following.


create table customers_lab05(
customerid int primary key,
customername varchar(255),
contactname varchar(255),
customeraddress varchar(255),
city varchar(255),
postalcode varchar(255),
country varchar(255),
)

insert into customers_lab05 values


(1, 'Alfreds Futterkiste', 'Maria Anders', 'Obere Str. 57', 'Berlin', '12209',
'Germany'),
(2, 'Ana Trujillo Emparedados y helados', 'Ana Trujillo', 'Avda. de la Constitución
2222', 'México D.F.', '05021', 'Mexico'),
(3, 'Antonio Moreno Taquería', 'Antonio Moreno', 'Mataderos 2312', 'México D.F.',
'05023', 'Mexico'),
(4, 'Around the Horn', 'Thomas Hardy', '120 Hanover Sq.', 'London', 'WA1 1DP', 'UK'),
(5, 'Berglunds snabbköp', 'Christina Berglund', 'Berguvsvägen 8', 'Lulea', 'S-958 22',
'Sweden');
SELECT * FROM customers_lab05

• Write an SQL statement that selects all Customers with a Country starting with
the letter
“s”.
SELECT * FROM customers_lab05
where country like 's%'
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION
ENGINEERING

COMPUTER ENGINEERING DEPARTMENT

Write an SQL statement that selects all Customers with a Contact Name ending with
the letter “s”.
SELECT * FROM customers_lab05
where country like '%s'

Write an SQL statement that selects all Customers with a City containing the pattern
“ndo”.
SELECT * FROM customers_lab05
where country like '%ndo%'

Write an SQL statement that selects all Customers with a City not containing the
pattern “ndo”.
SELECT * FROM customers_lab05
where country not like '%ndo%'

Write an SQL statement that selects the two first Customers from table who belong
to “Germany” or “Sweden”.
SELECT top 2 * FROM customers_lab05
where country in ('Germany' , 'Sweden');
Write an SQL statement that selects all Customers with a City of "Paris" or "London"
without using ‘OR’ operator.
SELECT * FROM customers_lab05
where city in ('paris' , 'london');

2. Consider the following table “Products”

create table products_lab05 (


productid int primary key ,
productname varchar(255),
supplierid int ,
categoryid int,
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION
ENGINEERING

COMPUTER ENGINEERING DEPARTMENT

unit varchar(255),
price decimal(5)
);
insert into products_lab05 values
(1, 'Chais', 1, 1, '10 boxes x 20 bags', 18),
(2, 'Chang', 1, 1, '24 - 12 oz bottles', 19),
(3, 'Aniseed Syrup', 1, 2, '12 - 550 ml bottles', 10),
(4, 'Chef Anton''s Cajun Seasoning', 1, 2, '48 - 6 oz jars', 22),
(5, 'Chef Anton''s Gumbo Mix', 1, 2, '36 boxes', 21.35);
select * from products_lab05

• Write an SQL statement that selects all products with a price from 10 to 20.

select * from products_lab05


where price between 10 and 20;

• Write an SQL statement that selects all products with a price from 20 to 30.
select * from products_lab05
where price between 20 and 30;

• Write an SQL statement that selects all products with a price from 10 to 22 but
products with a CategoryIDof 1,2, or 3 should not be displayed.

select * from products_lab05


where (price between 10 and 20)
and
(categoryid not in (1,2,3));
select * from products_lab05
where price between 10 and 20;

• Write an SQL statement that selects all products with a ProductName


beginning with any of the letter not between 'C' and 'M'.

select * from products_lab05


where productname not between 'c%' and '%m';

You might also like