SQL Left 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. This is also known as LEFT (OUTER) JOIN.

LEFT (OUTER) JOIN

Left Join Syntax :

The syntax of the Left Join is −

SELECT column-name(s)
FROM table1
LEFT JOIN table2
ON table1.column-name = table2.column-name;



SQL Left Join Example :

Consider the Customer table with the following records -

ID Name Age Address Salary
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


Consider the Order table with the following records -

OID Date CustomerID Amount
102 2019-10-08 00:00:00 3 3000
100 2019-10-08 00:00:00 3 1500
101 2019-11-20 00:00:00 2 1800
103 2018-05-20 00:00:00 4 2500


TEST CASE 1 :-Let us join these two tables using the Left JOIN as follows

SELECT  ID, Name, Amount, Date
FROM Customer
LEFT JOIN Order
ON Customer.ID = Order.CustomerID;


The result for the respective sql query is as follows −

ID Name Amount Date
1 Aarav NULL NULL
2 Vivaan 1800 2019-11-20 00:00:00
3 Reyansh 3000 2019-10-08 00:00:00
3 Reyansh 1500 2019-10-08 00:00:00
4 Muhammad 2500 2018-05-20 00:00:00
5 Sai NULL NULL




Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

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

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

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

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

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

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

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

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

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

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

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

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

pHqghUme
-1' OR 2+899-899-1=0+0+0+1 or 'KazGpE1A'='

pHqghUme
-1' OR 3+899-899-1=0+0+0+1 or 'KazGpE1A'='

pHqghUme
-1' OR 3*2<(0+5+899-899) or 'KazGpE1A'='

pHqghUme
-1' OR 3*2>(0+5+899-899) or 'KazGpE1A'='

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

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

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

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

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
DOx0Bxfo'; waitfor delay '0:0:15' --

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

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

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

pHqghUme
UUt58rT3' OR 869=(SELECT 869 FROM PG_SLEEP(15))--

pHqghUme
x5TRfNRJ') OR 443=(SELECT 443 FROM PG_SLEEP(15))--

pHqghUme
sFABZsom')) OR 369=(SELECT 369 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
@@FFRXr

pHqghUme
555

pHqghUme
555

pHqghUme
555