SQL Tutorial 9: SQL Joins

preview_player
Показать описание
SQL Fundamentals and Features for Database Developers, Administrators, and Testers. Create Database, Tables, and Insert Records into the Tables using SQL Statements.
Using SQL Select, Where clause, and SQL Operators join the two Tables, and create result Table.
Launch MS SQL Server Database Engine, Write & Execute SQL Data Definition Language Commands and Data Manipulation Language Commands.
Рекомендации по теме
Комментарии
Автор

Class Notes...
SQL Tutorial 9: SQL Joins

The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.

Consider the following two tables -

Table 1 - CUSTOMERS with ID, NAME, AGE, and CITY Fields...
Table 2 - ORDERS Table with ID, Item, and Amount Fields...

Combine these two tables and create a Result table with ID, NAME, and Amount Fields

Steps:
//Create a Database
Create Database gcreddyDB;

Use Database;

//Create a Table in the Database,
Create Table Customers
(
ID int,
Name char(40),
Age int;
City char(30);
);

//Insert Data...
Insert Into Customers(Id, Name, Age, City)
values(1, 'Ramesh', 32, 'Hyderabad'),
(2, 'Prasad', 25, 'Delhi'),
(3, 'Venkat', 23, 'Mumbai'),
(4, 'Ramya', 25, 'Chennai');

//Create another table
Create Table Orders
(
OrderNo int,
Item char(30),
Amount int;
);

//Insert Data...
Insert Into Customers(OrderNo, Item, Amount)
values(2, 'TV', 5000),
(3, 'Fridge', 4000),
(4, 'AC', 23, 6000);

Table 1 - Customers Table
ID Name Age City
1 Ramesh 32 Hyderabad
2 Prasad 25 Delhi
3 Venkat 23 Chennai
4 Ramya 25 Mumbai

Table 2 - ORDERS Table
OrderNo Item Amount
2 TV 5000
3 Fridge 6000
4 AC 8000

Display Tables one by one,

Select * from Customers;
Select * from Orders;

Now, let us join these two tables in our SELECT statement as shown below.

SQL> SELECT ID, NAME, AGE, AMOUNT
FROM CUSTOMERS, ORDERS
WHERE CUSTOMERS.ID = ORDERS.OrderNo;
This would produce the following result.
ID Name Item Amount
2 Prasad TV 5000
3 Venkat Fridge 6000
4 Ramya AC 8 000

Note: Here, it is noticeable that the join is performed in the WHERE clause. Several operators can be used to join tables, such as =, <, >, <>, <=, >=, !=, BETWEEN, LIKE, and NOT; they can all be used to join tables. However, the most common operator is the equal to symbol.

gcreddy
Автор

Stay blessed Sir for educating us with your knowledge and selfless teaching beautifully.

tubeexplorer
Автор

Part 2 undha sir? Cause joins naku yekkada kanabadale

bharathreddy
Автор

hi GCredddy, you have classes on Hadoop, mangocasandera ?

aavlogsusa
Автор

Thank you so much for sharing as your videos are very high standards....big applaud to you

satindersaini
Автор

Super explanation sir, thank so much sir

hemakandati
Автор

Inner join, left join, right join, full outer join, Is there a video for that?

saranoor
Автор

Thanks a lot Sir. Admire your dedication !

lavanyac
Автор

Sir what is different between joints and union, intersection, mines.

mounikamou
Автор

Thanks a lot sir.. all things r nice but it seems some more topic related to joins like inner join, left join, right join, full outer join are still remains.. so i request please cover these topic in ur next video. Thank u sir 🙏

piyushagnihotri
Автор

Sir, Can you please provide the notes for this video?

sreeyash
Автор

everything is nice bt it seems, many topic related to joins it is not covered inner, outer.. etc

ishanus
Автор

sir upload full joins videos left right full joins etc pls

rahulgehlot