Professional Documents
Culture Documents
1. Nested Subqueries
Ans:
SQL provides a mechanism for subqueries. Earth subquery is a
select-from-where expression that is nested within another
query.
Lets See About
SET MEMBERSHIP
SET COMPARISON
SET CO-ORDINALITY
SET MEMBERSHIP:
It allows testing tuples for membership in a relation.
The in-connectives tests for set membership where these set is a
collection of values produced by a select clause.
The not in connective tests for the absence of set membership.
Query for all account holders at the bank who are the members
of the set of borrowers from the bank.
Select distinct customer_name
From borrower
Where customer_name in [ Select customer name from
depositor]
SET COMPARISON:
The phrase “Greater than at least one” is represented in SQL
by > some
Select branch name
From branch
Where asserts some [ Select assets from branch where
branch.city=’Chennai’]
The Subquery [ Select assets from branch where
branch.city=’Chennai’] Generates the set of all assert values
branches in Chennai . The > some comparison in the where
clause of the outer select is true is the assets value of the tuple is
greater than at least one member of the set of all asset values for
branches in Chennai.
Exits
Non-Exits
Except
Unique
Non-Unique
SQL joins
Types of joints
INNER JOIN
LEFT OUTER JOIN
RIGHT OUTER JOIN
FULL OUTER JOIN
INNER JOIN:
Definition:
It returns all rows from the right hand table specified in the on
condition and only those rows from the other table where the
joined fields are equal.
Definition:
It returns all rows from the left hand table and right hand table
with the null values in place where the joied condition is not
met.