0 votes
in MariaDB by
What is LEFT OUTER JOIN in MariaDB?

1 Answer

0 votes
by

MariaDB LEFT OUTER JOIN is used to return all rows from the left-hand table specified in the ON condition and only those rows from the other table where the joined condition is satisfied.

LEFT OUTER JOIN is also called LEFT JOIN.

Syntax:

SELECT columns      

FROM table1      

LEFT [OUTER] JOIN table2      

ON table1.column = table2.column;      

Example

We have two tables' sites and pages:

Sites table:

site_id site_name

100 javatpoint.com

200 Facebook.com

300 Yahoo.com

400 Google.com

Pages table:

page_id site_id page_title

1 100 MariaDB

2 100 MySQL

3 200 Java interview questions

4 300 Software testing

5 500 Flight booking

Now execute the following commands:

SELECT sites.site_id, sites.site_name, pages.page_id, pages.page_title FROM sites LEFT JOIN pages ON sites.site_id= pages.site_id  

Output:

site_id site_name page_id page_title

100 javatpoint 1 MariaDB

100 javatpoint 2 MySQL

200 Facebook.com 3 Java interview questions

300 Yahoo.com 4 Software testing

400 Google.com null null

Site_name Google.com is also included because of LEFT JOIN.

Related questions

0 votes
asked Jan 3 in MariaDB by rajeshsharma
0 votes
asked Jan 3 in MariaDB by rajeshsharma
...