Page 1
SQL: Structured Ouery language (SOL) is a language that provides an interface to
rel ationdatabase systems. SOL was developed by IBM in the 1970, for use in
system R and is a defector standard, as well as an ISO and ANSI standard.
Sequences
+ Triggers
User Defined Functions' (UDFs)
Stored procedure
Database application objects * •
Database objects
• To deal with the above database objects, we need a programming language
and that programming languages is known as SOL.
Three subordinate languages of SOL are
Data Definition Language (DDL)
It includes the commands as
• CREATE To create tables in the database.
• ALTER To modify the existing table structure:
• DROP To drop the table with table structure.
• Data Manipulation Language (DML) It is1 used to insert, delete, update data
and perform queries on these tables. Some of the DML commands are given
below.
• INSERT To insert data into the table.
• SELECT To retrieve data from the table.
• UPDATE To-update existing data in the table.
• DELETE To delete data from the table.
Schetyn
Table
View
Index
Synonyms/Alias
Page 2
SQL: Structured Ouery language (SOL) is a language that provides an interface to
rel ationdatabase systems. SOL was developed by IBM in the 1970, for use in
system R and is a defector standard, as well as an ISO and ANSI standard.
Sequences
+ Triggers
User Defined Functions' (UDFs)
Stored procedure
Database application objects * •
Database objects
• To deal with the above database objects, we need a programming language
and that programming languages is known as SOL.
Three subordinate languages of SOL are
Data Definition Language (DDL)
It includes the commands as
• CREATE To create tables in the database.
• ALTER To modify the existing table structure:
• DROP To drop the table with table structure.
• Data Manipulation Language (DML) It is1 used to insert, delete, update data
and perform queries on these tables. Some of the DML commands are given
below.
• INSERT To insert data into the table.
• SELECT To retrieve data from the table.
• UPDATE To-update existing data in the table.
• DELETE To delete data from the table.
Schetyn
Table
View
Index
Synonyms/Alias
Data Control Language (DCL)
It' is used to control user's access to the database objects. Some of the DCL
commands are:
• GRANT Used to grant select/insert/delete access.
• REVOKE Used to revoke the provided access
Transaction Control Language (TCL): It is used to manage changes affecting the
data.
• COMMIT To save the work done, such as inserting or updating or deleting
data to/from the table.
• ROLLBACK To restore database to the original state, since last commit.
• SQL Data Types SQL data types specify the type, size and format of
data/information that can be stored in columns and variables.
Constraint Types with Description
N a m e o f
c o n s tr a in t
T a b le leveL'coLniiin le v e l/R o tv
le v e lE x te r n a l level
D e s c rip tio n
N O T
N U L L
C o lu m n LeveL
R e stric ts a co lu m n b y m a k in g it
m a n d a to ry to L ave so m e v alu e.
U n iq u e T a b le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le
P rim ary
k e y
C o lu m n Level a n d T ab le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le a n d
d isallo w s N U L L v a lu es.
C h e c k
C o n stra in t
C o lu m n Level
R o w Level E x te rn a l lev el
R e stric t a co lu m n v a lu e to a set o f
v alu es d e fin e d b y th e c o n strain t.
F o re ig n
k e y
c o n strain t
C o lu m n Level
E x te rn a l lev el
R e stric t th e v alu es th a t a re a c c e p ta b le
in a co lu m n or g ro u p o f co lu m n s o f a
ta b le to th o s e v alu es fo u n d in a listin g
o f th e c o lu n m /g ro u p o f co lu m n s u s e d
to d e fin e th e p rim ary k e y in o th e r
tab le.
Default Constraint: It is used to insert a default value into a column, if no other
value is specified at the time of insertion.
Syntax
CREATE TABLE Employee
{
Empjdint NOT NULL,
Last_Name varchar (250),
City varchar (50)OEFAULT *BANGALURU*
}
DDL Commands 1 2 3 4
1. CREATE TABLE < Tabl e_Name> { Col umn_name 1 < datatype > ,
Column_name 2 < d'ltajtype > }
2. ALTER TABLE < Table_Name> ALTER Column < Column_Name> SET NOT NULL
3. RENAME < objectjtype >object_name > to <new_name>
4. DROP TABLE <Table_Name>
Page 3
SQL: Structured Ouery language (SOL) is a language that provides an interface to
rel ationdatabase systems. SOL was developed by IBM in the 1970, for use in
system R and is a defector standard, as well as an ISO and ANSI standard.
Sequences
+ Triggers
User Defined Functions' (UDFs)
Stored procedure
Database application objects * •
Database objects
• To deal with the above database objects, we need a programming language
and that programming languages is known as SOL.
Three subordinate languages of SOL are
Data Definition Language (DDL)
It includes the commands as
• CREATE To create tables in the database.
• ALTER To modify the existing table structure:
• DROP To drop the table with table structure.
• Data Manipulation Language (DML) It is1 used to insert, delete, update data
and perform queries on these tables. Some of the DML commands are given
below.
• INSERT To insert data into the table.
• SELECT To retrieve data from the table.
• UPDATE To-update existing data in the table.
• DELETE To delete data from the table.
Schetyn
Table
View
Index
Synonyms/Alias
Data Control Language (DCL)
It' is used to control user's access to the database objects. Some of the DCL
commands are:
• GRANT Used to grant select/insert/delete access.
• REVOKE Used to revoke the provided access
Transaction Control Language (TCL): It is used to manage changes affecting the
data.
• COMMIT To save the work done, such as inserting or updating or deleting
data to/from the table.
• ROLLBACK To restore database to the original state, since last commit.
• SQL Data Types SQL data types specify the type, size and format of
data/information that can be stored in columns and variables.
Constraint Types with Description
N a m e o f
c o n s tr a in t
T a b le leveL'coLniiin le v e l/R o tv
le v e lE x te r n a l level
D e s c rip tio n
N O T
N U L L
C o lu m n LeveL
R e stric ts a co lu m n b y m a k in g it
m a n d a to ry to L ave so m e v alu e.
U n iq u e T a b le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le
P rim ary
k e y
C o lu m n Level a n d T ab le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le a n d
d isallo w s N U L L v a lu es.
C h e c k
C o n stra in t
C o lu m n Level
R o w Level E x te rn a l lev el
R e stric t a co lu m n v a lu e to a set o f
v alu es d e fin e d b y th e c o n strain t.
F o re ig n
k e y
c o n strain t
C o lu m n Level
E x te rn a l lev el
R e stric t th e v alu es th a t a re a c c e p ta b le
in a co lu m n or g ro u p o f co lu m n s o f a
ta b le to th o s e v alu es fo u n d in a listin g
o f th e c o lu n m /g ro u p o f co lu m n s u s e d
to d e fin e th e p rim ary k e y in o th e r
tab le.
Default Constraint: It is used to insert a default value into a column, if no other
value is specified at the time of insertion.
Syntax
CREATE TABLE Employee
{
Empjdint NOT NULL,
Last_Name varchar (250),
City varchar (50)OEFAULT *BANGALURU*
}
DDL Commands 1 2 3 4
1. CREATE TABLE < Tabl e_Name> { Col umn_name 1 < datatype > ,
Column_name 2 < d'ltajtype > }
2. ALTER TABLE < Table_Name> ALTER Column < Column_Name> SET NOT NULL
3. RENAME < objectjtype >object_name > to <new_name>
4. DROP TABLE <Table_Name>
DML Commands
SELECT Ai, A2 , A3....,An what to return
FROM Ri, R 2 , R 3 i ...., Rm relations or table
WHERE condition filter condition i.e., on what basis, we want to restrict the
outcome/result.
If we want to write the above SQL script in the form of relational calculus, we use
the following syntax
{ E l A. -A. ( * — n ( R l > < R : X X R m ))}
Comparison operators which we can use in filter condition are (=, >,<,> = ,<=,< >,)
'< >’ means not equal to.
INSERT Statement: Used to add row (s) to the tables in a database
INSERT INTO Employee (F_Name, L_Name) VALUES (Atal1 , 'Bihari')
UPDATE Statement: It is used to modify/update or change existing data in single
row, group of rows or all the rows in a table.
Example: //Updates some rows in a table. UPDATE Employee SET City = 'LUCKNOW’
WHERE Empjd BETWEEN 9 AND 15; //Update city column for all the rows UPDATE
Employee SET City=’LUCKNOW’;
DELETE Statement
This is used to delete rows from a table,
Example:
//Following query will delete all the rows from Employee table DELETE Employee
Emp_ld=7; DELETE Employee
ORDER BY Clause: This clause is used to, sort the result of a query in a specific
order (ascending or descending), by default sorting order is ascending.
SELECT Empjd, Emp_Name, City FROM Employee
WHERE City = 'LUCKNOW'
ORDER BY Empjd DESC;
GROUP BY Clause: It is used to divide the result set into groups. Grouping can be
done by a column name or by the results of computed columns when using
numeric data types.
• The HAVING clause can be used to set conditions for the GROUPBY clause.
• HAVING clause is similar to the WHERE clause, but having puts conditions on
groups.
• WHERE clause places conditions on rows.
• WHERE clause can’t include aggregate: function, while HAVING conditions can
do so.
Example:
SELECT Empjd, AVG (Salary)
FROM Employee
GROUP BY Empjd
HAVING AVG (Salary) > 25000;
Aggregate Functions
Page 4
SQL: Structured Ouery language (SOL) is a language that provides an interface to
rel ationdatabase systems. SOL was developed by IBM in the 1970, for use in
system R and is a defector standard, as well as an ISO and ANSI standard.
Sequences
+ Triggers
User Defined Functions' (UDFs)
Stored procedure
Database application objects * •
Database objects
• To deal with the above database objects, we need a programming language
and that programming languages is known as SOL.
Three subordinate languages of SOL are
Data Definition Language (DDL)
It includes the commands as
• CREATE To create tables in the database.
• ALTER To modify the existing table structure:
• DROP To drop the table with table structure.
• Data Manipulation Language (DML) It is1 used to insert, delete, update data
and perform queries on these tables. Some of the DML commands are given
below.
• INSERT To insert data into the table.
• SELECT To retrieve data from the table.
• UPDATE To-update existing data in the table.
• DELETE To delete data from the table.
Schetyn
Table
View
Index
Synonyms/Alias
Data Control Language (DCL)
It' is used to control user's access to the database objects. Some of the DCL
commands are:
• GRANT Used to grant select/insert/delete access.
• REVOKE Used to revoke the provided access
Transaction Control Language (TCL): It is used to manage changes affecting the
data.
• COMMIT To save the work done, such as inserting or updating or deleting
data to/from the table.
• ROLLBACK To restore database to the original state, since last commit.
• SQL Data Types SQL data types specify the type, size and format of
data/information that can be stored in columns and variables.
Constraint Types with Description
N a m e o f
c o n s tr a in t
T a b le leveL'coLniiin le v e l/R o tv
le v e lE x te r n a l level
D e s c rip tio n
N O T
N U L L
C o lu m n LeveL
R e stric ts a co lu m n b y m a k in g it
m a n d a to ry to L ave so m e v alu e.
U n iq u e T a b le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le
P rim ary
k e y
C o lu m n Level a n d T ab le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le a n d
d isallo w s N U L L v a lu es.
C h e c k
C o n stra in t
C o lu m n Level
R o w Level E x te rn a l lev el
R e stric t a co lu m n v a lu e to a set o f
v alu es d e fin e d b y th e c o n strain t.
F o re ig n
k e y
c o n strain t
C o lu m n Level
E x te rn a l lev el
R e stric t th e v alu es th a t a re a c c e p ta b le
in a co lu m n or g ro u p o f co lu m n s o f a
ta b le to th o s e v alu es fo u n d in a listin g
o f th e c o lu n m /g ro u p o f co lu m n s u s e d
to d e fin e th e p rim ary k e y in o th e r
tab le.
Default Constraint: It is used to insert a default value into a column, if no other
value is specified at the time of insertion.
Syntax
CREATE TABLE Employee
{
Empjdint NOT NULL,
Last_Name varchar (250),
City varchar (50)OEFAULT *BANGALURU*
}
DDL Commands 1 2 3 4
1. CREATE TABLE < Tabl e_Name> { Col umn_name 1 < datatype > ,
Column_name 2 < d'ltajtype > }
2. ALTER TABLE < Table_Name> ALTER Column < Column_Name> SET NOT NULL
3. RENAME < objectjtype >object_name > to <new_name>
4. DROP TABLE <Table_Name>
DML Commands
SELECT Ai, A2 , A3....,An what to return
FROM Ri, R 2 , R 3 i ...., Rm relations or table
WHERE condition filter condition i.e., on what basis, we want to restrict the
outcome/result.
If we want to write the above SQL script in the form of relational calculus, we use
the following syntax
{ E l A. -A. ( * — n ( R l > < R : X X R m ))}
Comparison operators which we can use in filter condition are (=, >,<,> = ,<=,< >,)
'< >’ means not equal to.
INSERT Statement: Used to add row (s) to the tables in a database
INSERT INTO Employee (F_Name, L_Name) VALUES (Atal1 , 'Bihari')
UPDATE Statement: It is used to modify/update or change existing data in single
row, group of rows or all the rows in a table.
Example: //Updates some rows in a table. UPDATE Employee SET City = 'LUCKNOW’
WHERE Empjd BETWEEN 9 AND 15; //Update city column for all the rows UPDATE
Employee SET City=’LUCKNOW’;
DELETE Statement
This is used to delete rows from a table,
Example:
//Following query will delete all the rows from Employee table DELETE Employee
Emp_ld=7; DELETE Employee
ORDER BY Clause: This clause is used to, sort the result of a query in a specific
order (ascending or descending), by default sorting order is ascending.
SELECT Empjd, Emp_Name, City FROM Employee
WHERE City = 'LUCKNOW'
ORDER BY Empjd DESC;
GROUP BY Clause: It is used to divide the result set into groups. Grouping can be
done by a column name or by the results of computed columns when using
numeric data types.
• The HAVING clause can be used to set conditions for the GROUPBY clause.
• HAVING clause is similar to the WHERE clause, but having puts conditions on
groups.
• WHERE clause places conditions on rows.
• WHERE clause can’t include aggregate: function, while HAVING conditions can
do so.
Example:
SELECT Empjd, AVG (Salary)
FROM Employee
GROUP BY Empjd
HAVING AVG (Salary) > 25000;
Aggregate Functions
S U M ( ) It re tu rn s to ta l sum o f th e v a lu es
in a co lum n
A V G ( ) It re tu rn s av erag e o f th e v a lu es
in a co lum n
C O U N T ( ) P ro v id e s n u m b e r o f n o n -n u ll
v alu es in a co lu m n .
M IN ( ) a n d M A X ( ) P ro v id e s lo w e st a n d h ig h e st
v a lu e re s p e c tiv e ly in a co lu m n .
C O U N T (*) C o u n ts to ta l n u m b e r o f ro w s in
a tab le.
Joins: Joins are needed to retrieve data from two tables' related rows on the basis
of some condition which satisfies both the tables. Mandatory condition to join is
that atleast one set of column (s) should be taking values from same domain in
each table.
Inner Join: Inner join is the most common join operation used in applications and
can be regarded as the default join-type. Inner join creates a new result table by
combining column values of two tables (A and B) based upon the join-predicate.
These may be further divided into three parts.
1. Equi Join (satisfies equality condition)
2. Non-Equi Join (satisfies non-equality condition)
3. Self Join (one or more column assumes the same domain of values).
Outer Join: An outer join does not require each record in the two joined tables to
have a matching record. The joined table retains each record-even if no other
matching record exists.
Considers also the rows from table (s) even if they don't satisfy the joining
condition
(i) Right outer join (ii) Left outer join (iii) Full outer join
Left Outer Join: The result of a left outer join for table A and B always contains all
records of the left table (A), even if the join condition does not find any matching
record in the right table (B).
ID Name
1 R a m
2 S hy am
T1
ID Brandi
1 IT
3 C S
L e ft O u te r Jo in
SELECT * FROM T1
Left Outer Join T2 ON T1
ID = T2 . ID
T1 T2
Result set of T1 and T2
T l. ID Name T2. ID Branch
1 R am 1 IT
2 S h y am N U L L N U L L
Page 5
SQL: Structured Ouery language (SOL) is a language that provides an interface to
rel ationdatabase systems. SOL was developed by IBM in the 1970, for use in
system R and is a defector standard, as well as an ISO and ANSI standard.
Sequences
+ Triggers
User Defined Functions' (UDFs)
Stored procedure
Database application objects * •
Database objects
• To deal with the above database objects, we need a programming language
and that programming languages is known as SOL.
Three subordinate languages of SOL are
Data Definition Language (DDL)
It includes the commands as
• CREATE To create tables in the database.
• ALTER To modify the existing table structure:
• DROP To drop the table with table structure.
• Data Manipulation Language (DML) It is1 used to insert, delete, update data
and perform queries on these tables. Some of the DML commands are given
below.
• INSERT To insert data into the table.
• SELECT To retrieve data from the table.
• UPDATE To-update existing data in the table.
• DELETE To delete data from the table.
Schetyn
Table
View
Index
Synonyms/Alias
Data Control Language (DCL)
It' is used to control user's access to the database objects. Some of the DCL
commands are:
• GRANT Used to grant select/insert/delete access.
• REVOKE Used to revoke the provided access
Transaction Control Language (TCL): It is used to manage changes affecting the
data.
• COMMIT To save the work done, such as inserting or updating or deleting
data to/from the table.
• ROLLBACK To restore database to the original state, since last commit.
• SQL Data Types SQL data types specify the type, size and format of
data/information that can be stored in columns and variables.
Constraint Types with Description
N a m e o f
c o n s tr a in t
T a b le leveL'coLniiin le v e l/R o tv
le v e lE x te r n a l level
D e s c rip tio n
N O T
N U L L
C o lu m n LeveL
R e stric ts a co lu m n b y m a k in g it
m a n d a to ry to L ave so m e v alu e.
U n iq u e T a b le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le
P rim ary
k e y
C o lu m n Level a n d T ab le Level
C h eck s w h e th e r a co lu m n v a lu e w ill b e
u n iq u e a m o n g a ll ro w s in a ta b le a n d
d isallo w s N U L L v a lu es.
C h e c k
C o n stra in t
C o lu m n Level
R o w Level E x te rn a l lev el
R e stric t a co lu m n v a lu e to a set o f
v alu es d e fin e d b y th e c o n strain t.
F o re ig n
k e y
c o n strain t
C o lu m n Level
E x te rn a l lev el
R e stric t th e v alu es th a t a re a c c e p ta b le
in a co lu m n or g ro u p o f co lu m n s o f a
ta b le to th o s e v alu es fo u n d in a listin g
o f th e c o lu n m /g ro u p o f co lu m n s u s e d
to d e fin e th e p rim ary k e y in o th e r
tab le.
Default Constraint: It is used to insert a default value into a column, if no other
value is specified at the time of insertion.
Syntax
CREATE TABLE Employee
{
Empjdint NOT NULL,
Last_Name varchar (250),
City varchar (50)OEFAULT *BANGALURU*
}
DDL Commands 1 2 3 4
1. CREATE TABLE < Tabl e_Name> { Col umn_name 1 < datatype > ,
Column_name 2 < d'ltajtype > }
2. ALTER TABLE < Table_Name> ALTER Column < Column_Name> SET NOT NULL
3. RENAME < objectjtype >object_name > to <new_name>
4. DROP TABLE <Table_Name>
DML Commands
SELECT Ai, A2 , A3....,An what to return
FROM Ri, R 2 , R 3 i ...., Rm relations or table
WHERE condition filter condition i.e., on what basis, we want to restrict the
outcome/result.
If we want to write the above SQL script in the form of relational calculus, we use
the following syntax
{ E l A. -A. ( * — n ( R l > < R : X X R m ))}
Comparison operators which we can use in filter condition are (=, >,<,> = ,<=,< >,)
'< >’ means not equal to.
INSERT Statement: Used to add row (s) to the tables in a database
INSERT INTO Employee (F_Name, L_Name) VALUES (Atal1 , 'Bihari')
UPDATE Statement: It is used to modify/update or change existing data in single
row, group of rows or all the rows in a table.
Example: //Updates some rows in a table. UPDATE Employee SET City = 'LUCKNOW’
WHERE Empjd BETWEEN 9 AND 15; //Update city column for all the rows UPDATE
Employee SET City=’LUCKNOW’;
DELETE Statement
This is used to delete rows from a table,
Example:
//Following query will delete all the rows from Employee table DELETE Employee
Emp_ld=7; DELETE Employee
ORDER BY Clause: This clause is used to, sort the result of a query in a specific
order (ascending or descending), by default sorting order is ascending.
SELECT Empjd, Emp_Name, City FROM Employee
WHERE City = 'LUCKNOW'
ORDER BY Empjd DESC;
GROUP BY Clause: It is used to divide the result set into groups. Grouping can be
done by a column name or by the results of computed columns when using
numeric data types.
• The HAVING clause can be used to set conditions for the GROUPBY clause.
• HAVING clause is similar to the WHERE clause, but having puts conditions on
groups.
• WHERE clause places conditions on rows.
• WHERE clause can’t include aggregate: function, while HAVING conditions can
do so.
Example:
SELECT Empjd, AVG (Salary)
FROM Employee
GROUP BY Empjd
HAVING AVG (Salary) > 25000;
Aggregate Functions
S U M ( ) It re tu rn s to ta l sum o f th e v a lu es
in a co lum n
A V G ( ) It re tu rn s av erag e o f th e v a lu es
in a co lum n
C O U N T ( ) P ro v id e s n u m b e r o f n o n -n u ll
v alu es in a co lu m n .
M IN ( ) a n d M A X ( ) P ro v id e s lo w e st a n d h ig h e st
v a lu e re s p e c tiv e ly in a co lu m n .
C O U N T (*) C o u n ts to ta l n u m b e r o f ro w s in
a tab le.
Joins: Joins are needed to retrieve data from two tables' related rows on the basis
of some condition which satisfies both the tables. Mandatory condition to join is
that atleast one set of column (s) should be taking values from same domain in
each table.
Inner Join: Inner join is the most common join operation used in applications and
can be regarded as the default join-type. Inner join creates a new result table by
combining column values of two tables (A and B) based upon the join-predicate.
These may be further divided into three parts.
1. Equi Join (satisfies equality condition)
2. Non-Equi Join (satisfies non-equality condition)
3. Self Join (one or more column assumes the same domain of values).
Outer Join: An outer join does not require each record in the two joined tables to
have a matching record. The joined table retains each record-even if no other
matching record exists.
Considers also the rows from table (s) even if they don't satisfy the joining
condition
(i) Right outer join (ii) Left outer join (iii) Full outer join
Left Outer Join: The result of a left outer join for table A and B always contains all
records of the left table (A), even if the join condition does not find any matching
record in the right table (B).
ID Name
1 R a m
2 S hy am
T1
ID Brandi
1 IT
3 C S
L e ft O u te r Jo in
SELECT * FROM T1
Left Outer Join T2 ON T1
ID = T2 . ID
T1 T2
Result set of T1 and T2
T l. ID Name T2. ID Branch
1 R am 1 IT
2 S h y am N U L L N U L L
Right Outer Join: A right outer closely resembles a left outer join, except with the
treatment of the tables reversed. Every row from the right table will appear in the1
joined table at least once. If no matching with left table exists, NULL will appear.
SELECT ’ FROM T , RIG HT
O UTER JO IN T2 O N T1 .1 0
=T2.ID
T l___________ J 2
R ight ou ter Join
10 Nam e
t Ram
2 Shyam
10 Branch
t IT
3 CS
Result set of T1 and T2
TI. ID Name T2. ID Branch
1 R am 1 IT
N U L L N U L L 3 C S
Full Outer Join: A full outer join combines the effect of applying both left and right
outer joins where records in the FULL OUTER JOIN table do not match, the result
set will have NULL values for every column of the table that lacks a matching row
for those records that do match, as single row will be produced in the result set.
SELECT' FROM T, FULL OUTER
JOIN T2 ON T1 . ID=T2.ID
Ti T 2
Result set of TI and T2 (Using tables of previous example)
TI. ID Name T2. ID Brand)
1 R a m 1 IT
2 S hy am N U L L N U L L
N U L L N U L L 3 C S
Cross Join (Cartesian product): Cross join returns the Cartesian product of rows
form tables in the join. It will produce rows which combine each row from the first
table with each row from the second table.
Select* FROM T1,T2
Number of rows in result set = (Number of rows in table 1 x Number of rows in
table 2)
Result set of TI and T2 (Using previous tables TI and T2)
ID Name ID Brand)
1 R a m 1 IT
2 S hy am 1 IT
1 R a m 3 C S
2 S hy am 3 C S
Read More