Anda di halaman 1dari 10

Presentation on MYSQL

Presented by : Rajesh Ramagiri


Now we are going to discusses on Joins
➢ Joins are used to get the combined data from two or more tables based on the
common fields.
We have multiple joins.
• INNER JOIN − returns rows when there is a match in both tables.
• LEFT JOIN − returns all rows from the left table, even if there are no matches in
the right table.
• RIGHT JOIN − returns all rows from the right table, even if there are no matches in
the left table.
• FULL JOIN − returns rows when there is a match in one of the tables.
• SELF JOIN − is used to join a table to itself as if the table were two tables,
temporarily renaming at least one table in the SQL statement.
• Let us now discuss Full join in detail.
We have multiple types of joins but why Full
joins
All joins gives us the common data from both tables or common data from both
tables and left table or right table.
But when it comes to Full join
• FULL JOIN returns all matching records from both tables whether the other table
matches or not.
• Full join can potentially return very large datasets.
• Full join and Full outer joins are the same.
Syntax of full join :
SELECT table1.column1, table2.column2...
FROM table1
FULL JOIN table2 ON table1.common_field = table2.common_field;
Union
• We can use union when we want to select rows one after the other several tables
or several rows from single table all as single result set.
• In union we can use order by clause in the last select statement, we can put each
select statement in parentheses and use the order by as last statement.
• Union operator select only distinct values by default, to allow duplicate values we
need to use UNION ALL.
In order to write union we need to consider some rules.
• The number and the order of the columns must be same in all the queries.
• The data types must me compatible.
• The columns selected in the different select statement must be in the same order.
• Syntax for union is,
SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
Index
• A database index is a data structure that improves the speed of operations in a
table. Indexes can be created using one or more columns.
• Indexes can create on one or more columns.
• We can create a unique index on a table. A unique index means that two rows
cannot have the same index value. Here is the syntax to create an Index on a
table.
CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...);
• Lets assume we have table data like this
•Any questions....?
•Thankyou

Anda mungkin juga menyukai