TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQL LEFT JOIN

SQL left join query with sql, tutorial, examples, insert, update, delete, select, join, database, table, join

<< Back to SQL

SQL LEFT JOIN

The SQL left join returns all the values from the left table and it also includes matching values from right table, if there are no matching join value it returns NULL.

BASIC SYNTAX FOR LEFT JOIN:

SELECT table1.column1, table2.column2....
FROM table1 
LEFTJOIN table2
ON table1.column_field = table2.column_field;

let us take two tables in this example to elaborate all the things:

CUSTOMER TABLE:

IDNAMEAGESALARY
1ARYAN5156000
2AROHI2125000
3VINEET2431000
4AJEET2332000
5RAVI2342000

This is second table

ORDER TABLE:

O_IDDATECUSTOMER_IDAMOUNT
00120-01-201223000
00212-02-201222000
00322-03-201234000
00411-04-201245000

join these two tables with LEFT JOIN:

SQL SELECT ID, NAME, AMOUNT,DATE
FROM CUSTOMER
LEFT JOIN ORDER
ON CUSTOMER.ID = ORDER.CUSTOMER_ID;

This will produce the following result:

IDNAMEAMOUNTDATE
1ARYANNULLNULL
2AROHI300020-01-2012
2AROHI200012-02-2012
3VINEET400022-03-2012
4AJEET500011-04-2012
5RAVINULLNULL
Next TopicSQL Right Join




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf