- A Part of a Bank Database

Projecting Specific Columns From a Table
- Eg: Project all customer names, their streets & cities listed in the customer table
SELECT customer_name, customer_street,customer_city

List List customer_city in the first column, and , customer_street in the second column in the second column
- We merely change the order of the projected attributes
SELECT customer_city, customer_street
FROM customer;
Notice that we have 2 sets of duplicate rows in the answer to our query. We
can eliminate these duplicate rows.

DISTINCT Keyword in SQL SELECT
- To Eliminate Duplicates in the Answer to our Query, use the DISTINCT Keyword in
SQL SELECT
SELECT distinct customer_city, customer_street
FROM customer;
- We have eliminated the duplicate rows in the answer to our query.

The Asterisk (*) in SELECT
- In Order to Project All Attributes: We Use The Asterisk ( * ) in SELECT
SELECT *
FROM customer;
is equivalent to
SELECT customer_name, customer_street, customer_city
FROM customer;

Project Specific Rows Which Satisfy a Predicate
SELECT *
FROM branch
WHERE branch_city = ‘kandy';
- In the “WHERE” clause, describe the predicate (i.e., condition which determines which rows are projected)
- E.g. Project all rows from branch which are branch city is ‘kandy’

No comments:
Post a Comment