In this video, we'll have a look at how to connect two tables together in SQL Server using LEFT and RIGHT JOINs.
My SQL Server Udemy courses are:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: https://rebrand.ly/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): https://rebrand.ly/database-fundamentals
70-462 SQL Server Database Administration (DBA): https://rebrand.ly/sql-server-dba
Microsoft SQL Server Reporting Services (SSRS): https://rebrand.ly/sql-server-ssrs
SQL Server Integration Services (SSIS): https://rebrand.ly/sql-server-ssis
SQL Server Analysis Services (SSAS): https://rebrand.ly/sql-server-ssas-mdx
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
----
LEFT and RIGHT JOINs enable you to retrieve all the rows of one table, and all of those rows in the other table which matches.
The code used in the video is:
DROP TABLE IF EXISTS table1;
DROP TABLE IF EXISTS table2;
CREATE TABLE table1
(Column1 int, Result1 char(1));
CREATE TABLE table2
(Column2 int, Result2 char(1));
INSERT INTO table1 VALUES
(3, 'a'), (5, 'b'), (6, 'c'), (7, 'd'), (8, 'e'), (9, 'f'), (16, 'g'), (17, 'h'),
(18, 'i'), (19, 'j');
INSERT INTO table2 VALUES
(16, 'G'), (17, 'H'), (18, 'I'), (19, 'J'), (20, 'K'), (21, 'L'), (22, 'M'),
(23, 'N'), (24, 'O'), (25, 'P'), (27, 'Q'), (28, 'R'), (29, 'S');
SELECT Column1, Result1, Result2
FROM table1
LEFT JOIN table2
ON table1.Column1 = table2.Column2;
SELECT Column2, Result1, Result2
FROM table1 AS T1
RIGHT JOIN table2 AS T2
ON T1.Column1 = T2.Column2;
----
Links to my website are:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: http://idodata.com/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): http://idodata.com/database-fundament...
SQL Server Essential in an Hour: http://idodata.com/sql-server-essenti...
70-462 SQL Server Database Administration (DBA): http://idodata.com/sql-server-databas...
DP-300: Administering Relational Databases: http://idodata.com/dp-300-administeri...
Microsoft SQL Server Reporting Services (SSRS): http://idodata.com/microsoft-sql-serv...
SQL Server Integration Services (SSIS): http://idodata.com/sql-server-integra...
SQL Server Analysis Services (SSAS): http://idodata.com/sql-server-ssas-mu...
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
1Z0-071 Oracle SQL Developer – certified associate: http://idodata.com/iz0-071-oracle-sql...
SQL for Microsoft Access: http://idodata.com/sql-for-microsoft-...
DP-900: Microsoft Azure Data Fundamentals: http://idodata.com/dp-900-microsoft-a...
Watch video SQL Server LEFT and RIGHT JOINs in 60 seconds online, duration hours minute second in high quality that is uploaded to the channel SQL Server 101 25 July 2024. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 616 times and liked it 14 visitors.