0% found this document useful (0 votes)
32 views

221902285-Database Lab Report 6

This lab report discusses querying and filtering data in MySQL tables. The objectives were to learn about using logical operators like AND and OR to filter data, comparing tables, and using limits. The student inserted sample data into tables, then wrote queries using WHERE, DISTINCT, ORDER BY, BETWEEN and other clauses to filter and sort the returned rows. The queries were tested and the outputs were displayed. The lab helped the student gain confidence in using SELECT statements to query databases.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

221902285-Database Lab Report 6

This lab report discusses querying and filtering data in MySQL tables. The objectives were to learn about using logical operators like AND and OR to filter data, comparing tables, and using limits. The student inserted sample data into tables, then wrote queries using WHERE, DISTINCT, ORDER BY, BETWEEN and other clauses to filter and sort the returned rows. The queries were tested and the outputs were displayed. The lab helped the student gain confidence in using SELECT statements to query databases.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Faculty of Sciences and Engineering
Semester: (Fall, Year:2023), B.Sc. in CSE (Day)

Lab Report No. #06


Course Title: Database Lab
Course Code: CSE-210 Section: 213-D11

Student Details

Name ID

1. Md. Tasnimur Rahman Shakir 221902285

Submission Date : 14.12.2023


Course Teacher’s Name : Md. Noyan Ali

Lab Report Status


Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................
1. TITLE OF THE LAB REPORT EXPERIMENT
Querying and Filtering data in MySQL Table
2. OBJECTIVES/AIM
• To gather knowledge about Querying and filtering data with logic gates like AND OR as well as using
limits.
• Learning about comparing tables in MySQL.
• To implement logic operations, comparisons and filtering data commands with limits in MySQL table.

3. PROCEDURE / ANALYSIS / DESIGN


In SQL, all logical operators evaluate TRUE, FALSE, or NULL ( UNKNOWN ). In MySQL, these
are implemented as 1 (TRUE ), 0 ( FALSE ), and NULL . ... Logical NOT. Evaluates to 1 if the
operand is 0, to 0 if the operand is nonzero, and NOT NULL returns NULL. MySQL provides a
LIMIT clause that is used to specify the number of records to return. The LIMIT clause makes it
easy to code multi page results or pagination with SQL and is very useful on large tables. Returning
many records can impact on performance. MySQL NOT BETWEEN AND operator checks
whether a value is not present between a starting and a closing expression. If expr is not greater
than or equal to mine and expr is not less than or equal to max, BETWEEN returns 1, otherwise, it
returns 0. The LIKE operator is used in a WHERE clause to search for a specified pattern in a
column.
4. IMPLEMENTATION
Question 1:
Input multiple data in any existing database table from previous lab report.

Query:

INSERT INTO branch (branch_name, branch_city, assets) VALUES ('Pollobi', 'Dhaka',


1000000), ('Uttora', 'Dhaka', 750000), ('Boshundhora', 'Dhaka', 600000);
INSERT INTO customer (customer_id, customer_name, customer_city) VALUES (1, 'Tasnim'
, 'Boshundhora'‘[email protected]’), (2, 'Mustakim', 'Pollobi',‘[email protected]’),
(3, 'Nur', 'Uttora',‘[email protected]’),VALUES (4,'Tasnim','Pollobi',
[email protected]’);
INSERT INTO account (account_number, branch_name, balance) VALUES (101, 'Pollobi',
50000), (102, 'Uttora', 7500), (103, 'Boshundhora', 12000),('104', 'Boshundhora',
'20000'), ('105', 'Uttora', '350000'),;
INSERT INTO loan (loan_number, branch_name, amount) VALUES (201, 'Pollobi', 30000),
(202, 'Uttora', 15000), (203, 'Boshundhora', 25000);
INSERT INTO depositor (customer_name, account_number) VALUES ('Tasnim', 101),
('Mustakim', 102), ('Nur', 103);
INSERT INTO borrower (customer_name, loan_number) VALUES ('Tasnim', 201),
('Mustakim', 202), ('Nur', 203);
Question 2: Query with primary key, query with condition, query with comparison operation.
Query:
SELECT customer_name, Email FROM `customer` ;
SELECT DISTINCT customer_id, customer_name FROM `customer` ;
SELECT loan_number, branch_name FROM `loan` WHERE amount > 15000;
SELECT loan_number, branch_name, amount FROM `loan` WHERE amount <> 25000;
SELECT Email FROM `customer` WHERE customer_name = 'Tasnim';
Question 3: Run all the queries using AND, OR, NOT, ORDER BY, ASC, DESC, Between, Not
Between In, Not In, LIKE.
Query:
SELECT * FROM `customer` WHERE city = 'Pollobi' AND customer_name = 'Tasnim';
SELECT * FROM customer WHERE customer_name = 'Tasnim' OR city = 'Pollobi';
SELECT * FROM customer WHERE NOT city = 'Pollobi' AND customer_name = 'Tasnim';
SELECT * FROM account ORDER BY balance DESC LIMIT 3;
SELECT * FROM account ORDER BY balance ASC LIMIT 1,3;
SELECT * FROM account WHERE balance BETWEEN 12000 AND 50000;
SELECT * FROM account WHERE balance NOT BETWEEN 12000 AND 50000;
SELECT * FROM account WHERE balance IN (12000,50000);
SELECT * FROM account WHERE balance NOT IN (12000,50000);
SELECT * FROM customer WHERE customer_name LIKE 'm%';
SELECT * FROM customer WHERE customer_name LIKE '%m';
SELECT * FROM customer WHERE customer_name LIKE '%ur%';
SELECT * FROM customer WHERE customer_name LIKE '_a_n%';

5. TEST RESULT / OUTPUT

Showing Inserted data of each Table of question 1:


Showing output from the query of question 2:
Swing output from the query of question 3:

S
6. Discussion
Based on the focused objective(s) to understand about the knowledge of SELECT, WHERE and DISTINCT
commands. The additional lab exercise made me more confident towards the fulfilment of the objectives(s)

You might also like