WHAT ARE SQL JOINS ? types of sql joins , structured query language, inner and outer joins.

Опубликовано: 09 Июнь 2023
на канале: DATA SERVE
38
1

hello folks ! myself minklesh and in this video we will stuuddyyyy what are SQL joins? I have created this video for study purpose for the people who are learning sql .
Lets go everyone!! In SQL (Structured Query Language), joins are used to combine data from two or more database tables based on a related or common column between the multiple tables. In SQL there are many types of SQL joins for performing various data retrieval. they are broadly classified as inner joins and outer join. the inner joins : they return only the rows that have matching values in both tables which are being joined. On the other hand, outer joins returns the rows that have matching and non-matching values in both tables which are being joined. Lets have a deep look over the each type of joins: first. inner joins, an inner joins returns only the rows that have matching values in both tables being joined. If there is no match between the tables, the rows will not be included in the result set or the output. It select records where the joins condition is satisfied in both tables. the resulting table will contain only the common rows from both tables. syntax for writing the inner join command is follows. select columns name, from which tables, then comes the inner join function which is betweeen the table1 and table2 on the basis of the condition or common column between the tables. example. as we can see that inner join is performned on the two tables that is, table customers and table orders. the common column between the 2 tables is the customer_id. so the command goes like, select customers.customer_id, customers.first_name,Orders.amount From customers, inner join orders, on customers.customer_id = orders.customer_id. in result table we can see that the columns like customer_id, first name and amount is selected and displayed. moving on to the outer joins, the outer joins returns the rows that have matching and non-matching values in both tables being joined. they are further classified into 3 type, right outer joins, left outer joins and full outer joins. lets have deep look at each types. starting with the right outer join. it returns all the rows from the right table and the matching rows from the left table, if there is no match in the left table then null values is used. syntax. Select function, then the columns names and then from funtions followed by first table name and then right outer join, then second table name and condition or the common column between the tables. example of right outer join. as we can see the customers and orders tables, column customer_id is common in both the tables, then we can perform the right outer join. by writing the sql query as. select Customers.customer_id, Customers.first_name, Orders.item FROM Customers, RIGHT JOIN Orders, ON, Customers.customer_id = Orders.customer_id; in the resulting table we can see that all the columns from right table that is customers table is presant in the resulting table and the non matching values from the left table are null values in the result table. coming to left oouter join. A left outer join returns all the rows from the left table and the matching rows from the right table. If there is no match in the right table, NULL values are used for the rows of the right table. The resulting table will contain all the rows from the left table and only the matching rows from the right table. syntax. SELECT, column1,column2, FROM table1, LEFT JOIN table2, ON, table1.column_name = table2.column_name. example. In the example of customers and orders tables we can perform the left outer joins. SELECT Customers.customer_id, Customers.first_name, Orders.amount FROM Customers, LEFT JOIN Orders, ON Customers.customer_id = Orders.customer_id. moving to the last outer join known as full outerjoin: A full outer join returns all the rows from the left table and the all rows from the right table. If there is no match , NULL values are used for the columns of the table. The resulting table will contain all the rows from the lefttable and all the rows from both the table. syntax SELECT column1,column2,...... FROM table1 FULL JOIN table2 ON table1.column_name = table2.column_name; lets see the working of full outer join with the customers tables and orders table to perform the full outer join write the query as SELECT Customers.customer_id, Customers.first_name, Orders.amount FROM Customers FULL OUTER JOIN Orders ON Customers.customer_id = Orders.customer; in the result we can see that all the rows from both the tables are present in the result table. thank you for watching hope the video was useful. do like the video and share it with your friends,and for more educational and tech related videos like this, do subscribe the channel dataserve.


Смотрите видео WHAT ARE SQL JOINS ? types of sql joins , structured query language, inner and outer joins. онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал DATA SERVE 09 Июнь 2023. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 38 раз и оно понравилось 1 посетителям.