12 Grouping Records, Joins in SQL
12 Grouping Records, Joins in SQL
joins in MySQL
CBSE
CLASS 12
The GROUP BY clause is used in SELECT statements to divide the table into two groups.
Grouping can be done by a column name, or with aggregate functions in which case the aggregate
produces a value for each group.
KRISH INFO TECH
example
example
KRISH INFO TECH
example
KRISH INFO TECH
example
If you include a non-group expression in the select
list of a query with GROUP BY, MySQL will not
produce any error.
Non-group Rather it will pick value of the specified non group
expressions field from the first row of the group.
with group by
But we do not recommend this practice because it
will produce ambiguous results.
KRISH INFO TECH
KRISH INFO TECH
example
joins
A joint is a query that combines rows from two or more tables.
In a join query, more than one table are listed in FROM clause.
• The join in which columns are compared for equality is called equi-join
• A non equi-join is a query that specifies some relationship other than equality between
the columns.
Equi-join and
Natural Join
natural join
• The join in which only one of the identical column exists is called natural join
The Equi-join and Natural Join are equivalent except that duplicate
columns are eliminated in the natural join that would otherwise appear in
the equi-join.
KRISH INFO TECH
Without ORDER BY
Order by
With ORDER BY
KRISH INFO TECH
KRISH INFO TECH
Follow and subscribe
https://www.youtube.com/@Krish_Info_Tech
sites.google.com/view/krishinfotech/home
@computer_tricks_nd_tips