SQL Join

The SQL join statement is used to join the data or records of two or more tables based on the corresponding column between them.There are four different types of SQL joins: inner, left, right, and full.The easiest and most common way to learn the difference between Sql joins is to use the Venn diagram.

SQL Join Example :

Consider the Product table with the following records -

ProductID CustomerID ProductCost ProductName
1000 2 500 Keyboards
1001 4 100 USB
1002 1 1500 Bags


Consider the Customer table with the following records -

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 36 Udaipur 35000
2 Vivaan 33 Mumbai 30000
3 Reyansh 28 Chennai 40000
4 Muhammad 29 Udaipur 50000
5 Sai 27 Mumbai 27000


TEST CASE 1 :- The "CustomerID" column in the "Product" table refers to the "CustomerID" in the "Customer" table. The relationship between the two tables above is the "CustomerID" column.
We can create the following SQL statement (containing an INNER JOIN), which selects the records that have matching values ​​in both tables.

SELECT Product.ProductID, Customer.CustomerName, Product.ProductName
FROM Product
INNER JOIN Customer ON Product.CustomerID=Customer.CustomerID;


The result for the respective sql query is as follows −

ProductID CustomerName ProductName
1000 Vivaan Keyboards
1001 Muhammad USB
1002 Aarav Bags



Different Types of SQL JOINs

Here are the different types of the JOINs in SQL:

INNER JOIN

Select all records from Table A and Table B, where the join condition is met. SQL inner joins are used to join data or records of two or more tables based on matching values ​​in both tables. The Inner Join will create the resulting set until the condition is satisfied by combining all rows from both tables.

LEFT (OUTER) JOIN

SQL Left Join is used to return all data or records from the Table 1 plus match records to tables 2. If there is no match, the result from the right will be NULL.

RIGHT (OUTER) JOIN

SQL Right Join is used to return all data or records from the Table 2 plus match records to tables 1. If there is no match, the result from the right will be NULL.

FULL (OUTER) JOIN

SQL Full Join is used to return all data or records when a match occurs in a Table 1 or Table 2 record and NULLs have to be filled in for missing matches on either side. It is also known as Full (OUTER) JOIN.





Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

pHqghUme
-1 OR 2+570-570-1=0+0+0+1 --

pHqghUme
-1 OR 3+570-570-1=0+0+0+1 --

pHqghUme
-1 OR 3*2<(0+5+570-570) --

pHqghUme
-1 OR 3*2>(0+5+570-570) --

pHqghUme
-1 OR 2+987-987-1=0+0+0+1

pHqghUme
-1 OR 3+987-987-1=0+0+0+1

pHqghUme
-1 OR 3*2<(0+5+987-987)

pHqghUme
-1 OR 3*2>(0+5+987-987)

pHqghUme
-1' OR 2+769-769-1=0+0+0+1 --

pHqghUme
-1' OR 3+769-769-1=0+0+0+1 --

pHqghUme
-1' OR 3*2<(0+5+769-769) --

pHqghUme
-1' OR 3*2>(0+5+769-769) --

pHqghUme
-1' OR 2+21-21-1=0+0+0+1 or '13P4rymU'='

pHqghUme
-1' OR 3+21-21-1=0+0+0+1 or '13P4rymU'='

pHqghUme
-1' OR 3*2<(0+5+21-21) or '13P4rymU'='

pHqghUme
-1' OR 3*2>(0+5+21-21) or '13P4rymU'='

pHqghUme
-1" OR 2+833-833-1=0+0+0+1 --

pHqghUme
-1" OR 3+833-833-1=0+0+0+1 --

pHqghUme
-1" OR 3*2<(0+5+833-833) --

pHqghUme
-1" OR 3*2>(0+5+833-833) --

pHqghUme
if(now()=sysdate(),sleep(15),0)

pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

pHqghUme
-1; waitfor delay '0:0:15' --

pHqghUme
-1); waitfor delay '0:0:15' --

pHqghUme
1 waitfor delay '0:0:15' --

pHqghUme
cJAvVKrN'; waitfor delay '0:0:15' --

pHqghUme
-5 OR 979=(SELECT 979 FROM PG_SLEEP(15))--

pHqghUme
-5) OR 700=(SELECT 700 FROM PG_SLEEP(15))--

pHqghUme
-1)) OR 62=(SELECT 62 FROM PG_SLEEP(15))--

pHqghUme
O3WL7amR' OR 718=(SELECT 718 FROM PG_SLEEP(15))--

pHqghUme
AIX9Ye2K') OR 416=(SELECT 416 FROM PG_SLEEP(15))--

pHqghUme
mgQiq2Rm')) OR 809=(SELECT 809 FROM PG_SLEEP(15))--

pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

pHqghUme
1'"

pHqghUme

pHqghUme
@@rHvQi

pHqghUme
555

pHqghUme
555

pHqghUme
555