Self Join and Cross Join in MS SQL Server Last Updated : 07 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite - Introduction of MS SQL Server 1. Self Join : Self-join allows us to join a table itself. It is useful when a user wants to compare the data (rows) within the same table. Syntax - select select_list from T t1 [Inner|Left] Join on T t2 on join_predicate. Here T refers to the table we use for comparison and it is referred twice. To avoid errors and confusion, t1 and t2 are used along T for comparing two rows in the same table. Inner join or Left join is used for self join to avoid errors. 2. Cross Join : Cross join allows us to join each and every row of both the tables. It is similar to the cartesian product that joins all the rows. Syntax - select select_list from T1 cross join T2 Example - Student and Course tables are picked from the university database. Table - Student Name Age Rollno Aisha 19 111 Maya 18 112 Naina 18 113 Table - Course Name Rollno Course Aisha 111 CSE Maya 112 EEE Naina 113 ECE 1. Self Join : A self-join is applied and the result set is the table below. select n1.name, n2.name from Student n1 inner join Student n2 on rollno n1 = rollno n2 NULL NULL 2. Cross Join : Cross join is applied and the result set is the fourth table. select * from Student cross join Course Name Age Rollno Name Rollno Course Aisha 19 111 Aisha 111 CSE Maya 18 112 Maya 112 EEE Naina 18 113 Naina 113 ECE Additional Articles - Full join and Inner join in MS SQL Server Left join and Right join in MS SQL Server Cross Join Comment More infoAdvertise with us Next Article Foreign key in MS SQL Server M mangalgiaishwarya2 Follow Improve Article Tags : SQL DBMS-SQL SQL-Server Similar Reads Left join and Right join in MS SQL Server Prerequisite â Introduction of MS SQL Server 1. Left Join : A join combines the set of two tables only. A left join is used when a user wants to extract the left table's data only. Left join not only combines the left table's rows but also the rows that match alongside the right table. Syntax - sele 2 min read SQL | Join (Cartesian Join & Self Join) In SQL, CARTESIAN JOIN (also known as CROSS JOIN) and SELF JOIN are two distinct types of joins that help combine rows from one or more tables based on certain conditions. While both joins may seem similar, they serve different purposes. Letâs explore both in detail.CARTESIAN JOINA Cartesian Join or 4 min read Joins in MS SQL Server A database comprises tables and each table in case of RDBMS is called a relation. Let us consider a sample database named University and it has two tables named Student and Marks. If a user wants to transfer a certain set of rows, insert into select statement is used along with the query. But if a u 2 min read SQL Joins (Inner, Left, Right and Full Join) SQL joins are fundamental tools for combining data from multiple tables in relational databases. Joins allow efficient data retrieval, which is essential for generating meaningful observations and solving complex business queries. Understanding SQL join types, such as INNER JOIN, LEFT JOIN, RIGHT JO 5 min read Foreign key in MS SQL Server A foreign key in SQL Server plays a crucial role in establishing and enforcing relationships between tables. It is a column or a set of columns in a table that references the primary key or a unique key in another table. By using foreign key constraints the SQL Server keeps data consistent between r 6 min read Insert Into Select statement in MS SQL Server The INSERT INTO SELECT statement in SQL Server is a versatile feature that enables you to efficiently copy data from one or more tables into another table. This functionality is essential for tasks such as data transfer, backup creation, and data merging.In this article, We will learn to Insert Into 4 min read Like