21. ORDER BY CLAUSE
ORDER BY clause is used to display the result of
a query in a specific order(sorted order).
The sorting can be done in ascending or in
descending order. It should be kept in mind that
the actual data in the database is not sorted but
only the results of the query are displayed in
sorted order.
Note:- If order is not specifies that by default the sorting will be
performed in ascending order.
22.
23. GROUP BY
The GROUP BY clause can be used in a SELECT statement to
collect data across multiple records and group the results by one or
more columns.
25. HAVING CLAUSE
The HAVING clause is used in combination with the GROUP BY
clause. It can be used in a SELECT statement to filter the records
that a GROUP BY returns.
26. JOINS
A JOIN is a query through which we can extract
queries from two or more tables. It means, it
combines rows from two or more tables. Rows in
one table can be joined to rows in another table
according to common values existing in
corresponding columns.
27. TYPES OF JOIN
There are various types of joins:
Cartesian Product
Equi Join
Non-Equi Join
Natural Join
28. CARTESIAN PRODUCT
OR
CROSS JOIN
The CROSS JOIN or CARTESIAN JOIN is used
to produce the Cartesian product of two tables.
The Cartesian product is a basic type of join that
matches each row from one table to every row
from another table.
32. EQUI JOIN
In an EQUI-JOIN operation, the values in the
columns are being joined and compared for equality.
All the columns in the tables being joined are
included in the results.
33. NON-EQUI JOIN
Non equi join is a query that specifies some
relationship other than equality between the
columns. It means that records are joined on the
condition other than Equal operator
(<,>,<>,>=,<=) for joining column.
35. NATURAL JOIN
The join in which one of the identical columns exist,
is called Natural Join. The natural join is much
similar to Equi-Join, records are joined on the
equality condition of joining column except that the
common column appears one time.
36. UNION
The UNION operator is used to combine the result-
set of two or more SELECT statements. Notice that
each SELECT statement within the UNION must
have the same number of columns. The columns
must also have similar data types. Also, the columns
in each SELECT statement must be in the same
order.
Note: The UNION operator selects only distinct
values by default. To allow duplicate values, use the
ALL keyword with UNION.
41. MINUS
MINUS is a little bit different. Let’s say we want
to see only book titles that are not also movie
titles. We need to “minus” everything from
the BOOK1 table that is also in
the BOOK2 table. The MINUS set operator is
designed for this type of task.
43. MINUS OPERATION IN MYSQL
MySqL does not support Minus operator so here we use left join to achieve
minus operation in MySQL.
44. INTERSECTION
An INTERSECT query returns the intersection of
2 or more data sets. If a record exists in both data
sets, it will be included in the INTERSECT
results. However, if a record exists in one data set
and not in the other, it will be omitted from the
INTERSECT results.