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

1 Answer

0 votes
by

MariaDB RIGHT OUTER JOIN is used to return all rows from the right-hand table specified in the ON condition and only those rows from the other table where the joined fields are satisfied with the conditions.

MariaDB RIGHT OUTER JOIN is also called RIGHT JOIN.

Syntax:

SELECT columns      

FROM table1      

RIGHT [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 RIGHT 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

null null 5 Flight booking

Here page_id and page_title contains value because of RIGHT JOIN.

...