0% found this document useful (0 votes)
21 views6 pages

Lab 4

Lab Manual for the Subject of Database Management System

Uploaded by

Bakht Khilji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

Lab 4

Lab Manual for the Subject of Database Management System

Uploaded by

Bakht Khilji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab # 04

Database management system


Fall 2021

Instructor

Student Name

CMSID

Department

Semester
Lesson Set Introduction to Boolean logic and
Between operator syntax
4
Purpose 1. To get basic awareness of Boolean logics
2. To understand the SQL AND, OR, & NOT
3. How and where we can use these Booleans
4. Create new table and use the Boolean logic and between operator

Procedure 1. Students should read the Pre-lab Reading assignment before coming to lab.
2. Students should complete the Pre-lab Writing assignment before coming to
lab.
3. In the lab, students should complete Labs 4.1 through 4.4 in sequence.
Your instructor will give further instructions as to grading and completion of
the lab.
4. Students should complete the set of lab tasks before the next lab and get
them checked by their lab instructor.

Contents Pre-requisites Completion Page


Time Number

Pre-lab Reading Assignment - 20 min 3

Pre-lab Writing Assignment Pre-lab Reading 10 min 5

Lab 4

Lab 4.1 Pre-lab reading 30 min 5


Recalling the SQL syntax

Lab 4.2 Awareness of - 6


Lab Tasks Syntax Rules

26 | P a g e
PRE-LAB READING ASSIGNMENT

Boolean Logics

Boolean Logic refers to the words " AND, OR, NOT" and their intended usage
with manipulating databases to either add, include, or subtract populated
information from a data set. In other words, Boolean Logic refers to the logical
approach (AND) instead of the arithmetical approach (+) to retrieve
information from any database that contains data sets. The arithmetical
approach refers to using symbols to convey addition as opposed to the logical
sense which uses words.
The importance of using Boolean Logic when searching through databases is
that it allows you to have control over what information the database will
populate through your search in order to increase the efficiency and relevancy
of your results.

Below you will find examples of each of the instances when you
would use Boolean Logic and the results they would generate.

AND Syntax

SELECT column1, column2, ...


FROM table_name ‫مت‬
WHERE condition1 AND condition2 AND condition3 ...;

OR Syntax

27 | P a g e
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;

NOT Syntax

SELECT column1, column2, ...


FROM table_name
WHERE NOT condition;

BETWEEN
Operator
The SQL BETWEEN condition allows you to easily test if an expression is
within a range of values (inclusive). The values can be text, date, or numbers.
It can be used in a SELECT, INSERT, UPDATE, or DELETE statement. The
SQL BETWEEN Condition will return the records where expression is within
the range of value1 and value2.

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

IN Operator
IN operator allows you to easily test if the expression matches any value in
the list of values. It is used to remove the need of multiple OR condition in
SELECT, INSERT, UPDATE or DELETE. You can also use NOT IN to
exclude the rows in your list. We should note that any kind of duplicate entry
will be retained.

SELECT column_name(s)
FROM table_name
WHERE column_name IN (list_of_values);

28 | P a g e
Pre lab writing assignment

Fill in the blanks 1. The __________ operator selects data if any one condition is true.

2. The SQL ___________ operator selects data if all conditions are true.

3. The SQL _________ operator selects data if the given condition is


false.

4. Between operator can be used with both ___________ and


_______________ values.

5. __________ operator is somehow the alternative of or operative

29 | P a g e
Lab 4.2 Lab Tasks

1. Use the 3.2.1 Database named by Courses and add new column by name fees using Alter
keyword syntax.

2. Write a query to Find all the students having first_name Between “A” and “K”. Using BETWEEN
with Date Values:

3. Write a query to Find the first_name, last_name of the students who have fees equal to 20000,
28000 or 25000.

4. Write a query to fetch all the records from the Student table where NAME is “yourChoice” OR
Age is greater then 17.

5. Write a query to fetch first_name, phone and email from the Student table where Age is 18 AND
first_name is “yourChoice” OR “yourChoice”.

6. Write a query to fetch all the records from the Student table where city is NOT equal to Quetta

30 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy