{"id":314,"date":"2024-11-25T16:12:18","date_gmt":"2024-11-25T09:12:18","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=314"},"modified":"2025-02-10T14:57:24","modified_gmt":"2025-02-10T07:57:24","slug":"postgresql-right-join","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/","title":{"rendered":"PostgreSQL Right Join"},"content":{"rendered":"\r\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the PostgreSQL <code>RIGHT JOIN<\/code> clause to merge rows of two tables.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='introduction-to-postgresql-right-join-clause'>Introduction to PostgreSQL RIGHT JOIN clause <a href=\"#introduction-to-postgresql-right-join-clause\" class=\"anchor\" id=\"introduction-to-postgresql-right-join-clause\" title=\"Anchor for Introduction to PostgreSQL RIGHT JOIN clause\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>RIGHT JOIN<\/code>\u00a0clause allows you to merge rows from two tables and\u00a0<em>return all rows from the right table with both <\/em>matching and unmatching rows from the left table.<\/p>\r\n\r\n\r\n\r\n<p>Here&#8217;s the syntax of the <code>RIGHT JOIN<\/code> clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  left_table.column1,\r\n  right_table.column2,\r\n  ...\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  left_table\r\n  <span class=\"hljs-keyword\">RIGHT JOIN<\/span> right_table <span class=\"hljs-keyword\">ON<\/span> right_table .column1 = left_table.column1;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>In this syntax:<\/p>\r\n\r\n\r\n\r\n<p>First, provide the name of the left table (<code>left_table<\/code>) in the\u00a0<code>FROM<\/code>\u00a0clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">FROM<\/span> left_table<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Second, specify the name of the right table (<code>right_table<\/code>) to join with the left table in the <code>RIGHT JOIN<\/code>\u00a0clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">RIGHT JOIN<\/span> right_table<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Third, use a condition for matching rows from the right table (<code>left_table<\/code>) with rows from the left table (<code>left_table<\/code>) in the\u00a0<code>ON<\/code>\u00a0clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">ON<\/span> right_table.column1 = left_table.column1;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>This condition matches rows by comparing the values of\u00a0<code>column1<\/code>\u00a0in\u00a0the right table (<code>right_table<\/code>)\u00a0with the values of\u00a0<code>column1<\/code>\u00a0in the left table (<code>left_table<\/code>).<\/p>\r\n\r\n\r\n\r\n<p>PostgreSQL always includes the row from the right table and the matching row from the left. Matching means both rows from tables have the same value in the <code>column1<\/code> columns.<\/p>\r\n\r\n\r\n\r\n<p>If a row from the right table does not have a matching row in the left table, PostgreSQL does the following:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Create a &#8220;fake&#8221; row with columns from the left table.<\/li>\r\n\r\n\r\n\r\n<li>Fill all the columns with <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-not-null\/\">NULL<\/a><\/li>\r\n\r\n\r\n\r\n<li>Merge with the &#8220;fake&#8221; row with the row from the right table.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>Finally, specify columns from both tables to include in the final result set in the\u00a0<code>SELECT<\/code>\u00a0clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  left_table.column1,\r\n  right_table.column2,\r\n  ...<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='understanding-postgresql-right-join'>Understanding PostgreSQL Right Join <a href=\"#understanding-postgresql-right-join\" class=\"anchor\" id=\"understanding-postgresql-right-join\" title=\"Anchor for Understanding PostgreSQL Right Join\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>Suppose you want to merge rows from <code>X<\/code> and <code>Y<\/code> tables using a right join:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>The <code>X<\/code> table has two columns: <code>id <\/code>(key) and <code>x<\/code>.<\/li>\r\n\r\n\r\n\r\n<li>The <code>Y<\/code> table also has two columns: <code>id<\/code> (key) and <code>y<\/code>.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\r\n<figure class=\"alignright size-full\"><img decoding=\"async\" class=\"wp-image-1951\" src=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/x-table.svg\" alt=\"PostgreSQL inner join: Left Table\" \/><\/figure>\r\n<\/div><\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\r\n<figure class=\"alignleft size-full\"><img decoding=\"async\" class=\"wp-image-1952\" src=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/y-table.svg\" alt=\"PostgreSQL inner join: Right Table\" \/><\/figure>\r\n<\/div><\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<p>The right join\u00a0includes all rows from the right table (<code>Y<\/code>) and matching rows from the left table (<code>X<\/code>).<\/p>\r\n\r\n\r\n\r\n<p>If a row in the right table does not have a matching row in the left table (<code>X<\/code>), the right join uses\u00a0<code>null<\/code>\u00a0for columns of the left table (<code>X<\/code>):<\/p>\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" class=\"wp-image-1963\" src=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/postgresql-right-join-visualization.svg\" alt=\"PostgreSQL right join visualization\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n<p>The following Venn diagram is another way to depict how a right join works:<\/p>\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" class=\"wp-image-1964\" src=\"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/postgresql-right-join-Venn-diagram.svg\" alt=\"PostgreSQL right join Venn diagram\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='postgresql-right-join-clause-example'>PostgreSQL RIGHT JOIN clause example <a href=\"#postgresql-right-join-clause-example\" class=\"anchor\" id=\"postgresql-right-join-clause-example\" title=\"Anchor for PostgreSQL RIGHT JOIN clause example\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>Suppose we have two tables <code>brands<\/code> and <code>products<\/code>:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> brands (\r\n  brand_id <span class=\"hljs-type\">INT<\/span> <span class=\"hljs-keyword\">GENERATED<\/span> <span class=\"hljs-keyword\">ALWAYS<\/span> <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">IDENTITY<\/span> <span class=\"hljs-keyword\">PRIMARY KEY<\/span>,\r\n  <span class=\"hljs-type\">name<\/span> <span class=\"hljs-type\">VARCHAR<\/span>(<span class=\"hljs-number\">255<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>\r\n);\r\n\r\n<span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> products (\r\n  product_id <span class=\"hljs-type\">INT<\/span> <span class=\"hljs-keyword\">GENERATED<\/span> <span class=\"hljs-keyword\">ALWAYS<\/span> <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">IDENTITY<\/span> <span class=\"hljs-keyword\">PRIMARY KEY<\/span>,\r\n  <span class=\"hljs-type\">name<\/span> <span class=\"hljs-type\">VARCHAR<\/span>(<span class=\"hljs-number\">100<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\r\n  price <span class=\"hljs-type\">DECIMAL<\/span>(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">2<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-keyword\">NULL<\/span>,\r\n  brand_id <span class=\"hljs-type\">INT<\/span>,\r\n  <span class=\"hljs-keyword\">FOREIGN KEY<\/span> (brand_id) <span class=\"hljs-keyword\">REFERENCES<\/span> brands (brand_id)\r\n);\r\n\r\n<span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span>\r\n  brands (<span class=\"hljs-type\">name<\/span>)\r\n<span class=\"hljs-keyword\">VALUES<\/span>\r\n  (<span class=\"hljs-string\">'Apple'<\/span>),\r\n  (<span class=\"hljs-string\">'Samsung'<\/span>),\r\n  (<span class=\"hljs-string\">'Google'<\/span>) \r\n<span class=\"hljs-keyword\">RETURNING<\/span> *;\r\n\r\n<span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span>\r\n  products (<span class=\"hljs-type\">name<\/span>, price, brand_id)\r\n<span class=\"hljs-keyword\">VALUES<\/span>\r\n  (<span class=\"hljs-string\">'iPhone 14 Pro'<\/span>, <span class=\"hljs-number\">999.99<\/span>, <span class=\"hljs-number\">1<\/span>),\r\n  (<span class=\"hljs-string\">'iPhone 15 Pro'<\/span>, <span class=\"hljs-number\">1199.99<\/span>, <span class=\"hljs-number\">1<\/span>),\r\n  (<span class=\"hljs-string\">'Galaxy S23 Ultra'<\/span>, <span class=\"hljs-number\">1149.47<\/span>, <span class=\"hljs-number\">2<\/span>),\r\n  (<span class=\"hljs-string\">'Oppo Find Flip'<\/span>, <span class=\"hljs-number\">499.99<\/span>, <span class=\"hljs-keyword\">NULL<\/span>) \r\n<span class=\"hljs-keyword\">RETURNING<\/span> *;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>The\u00a0<code>products<\/code>\u00a0table has a foreign key column,\u00a0<code>brand_id<\/code>, which references the <code>brand_id<\/code>\u00a0<a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-primary-key\/\">primary key<\/a>\u00a0column of the\u00a0<code>brands<\/code>\u00a0table.<\/p>\r\n\r\n\r\n\r\n<p>The <code>brands<\/code> table:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>brand_id<\/th>\r\n<th>name<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>1<\/td>\r\n<td>Apple<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>2<\/td>\r\n<td>Samsung<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td>Google<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The <code>products<\/code> table:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>product_id<\/th>\r\n<th>name<\/th>\r\n<th>price<\/th>\r\n<th>brand_id<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>1<\/td>\r\n<td>iPhone 14 Pro<\/td>\r\n<td>999.99<\/td>\r\n<td>1<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>2<\/td>\r\n<td>iPhone 15 Pro<\/td>\r\n<td>1299.99<\/td>\r\n<td>1<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td>Galaxy S23 Ultra<\/td>\r\n<td>1149.47<\/td>\r\n<td>2<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>4<\/td>\r\n<td>Oppo Find Flip<\/td>\r\n<td>499.99<\/td>\r\n<td>NULL<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The following statement uses the <code>RIGHT JOIN<\/code> clause to select all rows from the <code>brands<\/code> table with the matching rows from the <code>products<\/code> table:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  brands.name <span class=\"hljs-keyword\">AS<\/span> brand_name,\r\n  products.name <span class=\"hljs-keyword\">AS<\/span> product_name,\r\n  products.price\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  products\r\n  <span class=\"hljs-keyword\">RIGHT JOIN<\/span> brands <span class=\"hljs-keyword\">ON<\/span> brands.brand_id = products.brand_id;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=join&amp;q=U0VMRUNUIGJyYW5kcy5uYW1lIEFTIGJyYW5kX25hbWUsIHByb2R1Y3RzLm5hbWUgQVMgcHJvZHVjdF9uYW1lLCBwcm9kdWN0cy5wcmljZSBGUk9NIHByb2R1Y3RzIFJJR0hUIEpPSU4gYnJhbmRzIE9OIGJyYW5kcy5icmFuZF9pZCA9IHByb2R1Y3RzLmJyYW5kX2lkOw\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\"> brand_name |   product_name   |  price\r\n------------+------------------+---------\r\n Apple      | iPhone 14 Pro    |  999.99\r\n Apple      | iPhone 15 Pro    | 1199.99\r\n Samsung    | Galaxy S23 Ultra | 1149.47\r\n Google     | NULL             |    NULL<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>How it works.<\/p>\r\n\r\n\r\n\r\n<p>First, the\u00a0<code>FROM<\/code>\u00a0clause examines each row in the <code>brands<\/code> table.<\/p>\r\n\r\n\r\n\r\n<p>Second, the\u00a0<code>RIGHT JOIN<\/code> clause compares values in the <code>brand_id<\/code>\u00a0column of each row in the <code>brands<\/code> table with values in the <code>brand_id<\/code> column\u00a0of each row in the\u00a0<code>products<\/code>\u00a0table.<\/p>\r\n\r\n\r\n\r\n<p>If they are equal, PostgreSQL merges the rows from both tables. If they are not equal, PostgreSQL creates a new row with the columns from the right table and columns from the left table filled with <code>NULL<\/code>.<\/p>\r\n\r\n\r\n\r\n<p>The brand with id 1 matches two rows in the <code>products<\/code> table:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>brand_id<\/th>\r\n<th>name<\/th>\r\n<th>product_id<\/th>\r\n<th>name<\/th>\r\n<th>price<\/th>\r\n<th>brand_id<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td><strong>1<\/strong><\/td>\r\n<td>Apple<\/td>\r\n<td>1<\/td>\r\n<td>iPhone 14 Pro<\/td>\r\n<td>999.99<\/td>\r\n<td><strong>1<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>1<\/strong><\/td>\r\n<td>Apple<\/td>\r\n<td>2<\/td>\r\n<td>iPhone 15 Pro<\/td>\r\n<td>1299.99<\/td>\r\n<td><strong>1<\/strong><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The brand with id 2 matches one row in the <code>products<\/code> table:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>brand_id<\/th>\r\n<th>name<\/th>\r\n<th>product_id<\/th>\r\n<th>name<\/th>\r\n<th>price<\/th>\r\n<th>brand_id<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td><strong>2<\/strong><\/td>\r\n<td>Samsung<\/td>\r\n<td>3<\/td>\r\n<td>Galaxy S23 Ultra<\/td>\r\n<td>1149.47<\/td>\r\n<td><strong>2<\/strong><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The brand with id 3 does not match any row in the <code>products<\/code> table. PostgreSQL creates a fake row for all columns corresponding to columns in the <code>products<\/code> table, fills them will <a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-not-null\/\">NULL<\/a> and merges with the row in the <code>brands<\/code> table:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>brand_id<\/th>\r\n<th>name<\/th>\r\n<th>product_id<\/th>\r\n<th>name<\/th>\r\n<th>price<\/th>\r\n<th>brand_id<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td><strong>1<\/strong><\/td>\r\n<td>Apple<\/td>\r\n<td>1<\/td>\r\n<td>iPhone 14 Pro<\/td>\r\n<td>999.99<\/td>\r\n<td><strong>1<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>1<\/strong><\/td>\r\n<td>Apple<\/td>\r\n<td>2<\/td>\r\n<td>iPhone 15 Pro<\/td>\r\n<td>1299.99<\/td>\r\n<td><strong>1<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>2<\/strong><\/td>\r\n<td>Samsung<\/td>\r\n<td>3<\/td>\r\n<td>Galaxy S23 Ultra<\/td>\r\n<td>1149.47<\/td>\r\n<td><strong>2<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td>Google<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>After examining all rows in the <code>brands<\/code> and <code>products<\/code> tables, PostgreSQL comes up with the following intermediate result:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>brand_id<\/th>\r\n<th>name<\/th>\r\n<th>product_id<\/th>\r\n<th>name<\/th>\r\n<th>price<\/th>\r\n<th>brand_id<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td><strong>1<\/strong><\/td>\r\n<td>Apple<\/td>\r\n<td>1<\/td>\r\n<td>iPhone 14 Pro<\/td>\r\n<td>999.99<\/td>\r\n<td><strong>1<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>1<\/strong><\/td>\r\n<td>Apple<\/td>\r\n<td>2<\/td>\r\n<td>iPhone 15 Pro<\/td>\r\n<td>1299.99<\/td>\r\n<td><strong>1<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td><strong>2<\/strong><\/td>\r\n<td>Samsung<\/td>\r\n<td>3<\/td>\r\n<td>Galaxy S23 Ultra<\/td>\r\n<td>1149.47<\/td>\r\n<td><strong>2<\/strong><\/td>\r\n<\/tr>\r\n<tr>\r\n<td>3<\/td>\r\n<td>Google<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>Third, return the columns specified in the <code>SELECT<\/code> statement:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table class=\"has-fixed-layout\">\r\n<thead>\r\n<tr>\r\n<th>brand_name<\/th>\r\n<th>product_name<\/th>\r\n<th>price<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>Apple<\/td>\r\n<td>iPhone 14 Pro<\/td>\r\n<td>999.99<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Apple<\/td>\r\n<td>iPhone 15 Pro<\/td>\r\n<td>1299.99<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Samsung<\/td>\r\n<td>Galaxy S23 Ultra<\/td>\r\n<td>1149.47<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Google<\/td>\r\n<td>NULL<\/td>\r\n<td>NULL<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='using-table-aliases'>Using table aliases <a href=\"#using-table-aliases\" class=\"anchor\" id=\"using-table-aliases\" title=\"Anchor for Using table aliases\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>A table alias is a temporary name you assign to a table during the query execution. The following statement uses table aliases for the <code>brands<\/code> and <code>products<\/code> tables:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  b.name <span class=\"hljs-keyword\">AS<\/span> brand_name,\r\n  p.name <span class=\"hljs-keyword\">AS<\/span> product_name,\r\n  p.price\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  products p\r\n  <span class=\"hljs-keyword\">RIGHT JOIN<\/span> brands b <span class=\"hljs-keyword\">ON<\/span> b.brand_id = b.brand_id;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=join&amp;q=U0VMRUNUIGIubmFtZSBBUyBicmFuZF9uYW1lLCBwLm5hbWUgQVMgcHJvZHVjdF9uYW1lLCBwLnByaWNlIEZST00gcHJvZHVjdHMgcCBSSUdIVCBKT0lOIGJyYW5kcyBiIE9OIGIuYnJhbmRfaWQgPSBiLmJyYW5kX2lkOw\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='postgresql-right-join-clause-with-the-using-syntax'>PostgreSQL RIGHT JOIN clause with the USING syntax <a href=\"#postgresql-right-join-clause-with-the-using-syntax\" class=\"anchor\" id=\"postgresql-right-join-clause-with-the-using-syntax\" title=\"Anchor for PostgreSQL RIGHT JOIN clause with the USING syntax\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>When joining two tables by comparing values from the same column names using the equal operator (<code>=<\/code>), you can use the\u00a0<code>USING<\/code>\u00a0clause syntax:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  left_table.column1,\r\n  right_table.column2\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  left_table\r\n  <span class=\"hljs-keyword\">RIGHT JOIN<\/span> right_table <span class=\"hljs-keyword\">USING<\/span> (column1);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>In this statement, we use the <code>USING<\/code> clause instead of the <code>ON<\/code> clause in the <code>RIGHT JOIN<\/code>.<\/p>\r\n\r\n\r\n\r\n<p>The following example joins the <code>brands<\/code> table with the <code>products<\/code> table using the <code>RIGHT JOIN<\/code> clause with the <code>USING<\/code> syntax:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  b.name brand_name,\r\n  p.name product_name,\r\n  p.price\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  products p\r\n  <span class=\"hljs-keyword\">RIGHT JOIN<\/span> brands b <span class=\"hljs-keyword\">USING<\/span> (brand_id);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.pgtutorial.com\/playground\/?db=join&amp;q=U0VMRUNUIGIubmFtZSBicmFuZF9uYW1lLCBwLm5hbWUgcHJvZHVjdF9uYW1lLCBwLnByaWNlIEZST00gcHJvZHVjdHMgcCBSSUdIVCBKT0lOIGJyYW5kcyBiIFVTSU5HIChicmFuZF9pZCk7\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Use the\u00a0<code>RIGHT JOIN<\/code>\u00a0clause to merge rows from two tables and return all rows from the right table with the matching rows from the left table.<\/li>\r\n\r\n\r\n\r\n<li>Use the\u00a0<code>USING<\/code> syntax when joining two tables using the same column name and equal operator.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='quiz'>Quiz <a href=\"#quiz\" class=\"anchor\" id=\"quiz\" title=\"Anchor for Quiz\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p><iframe loading=\"lazy\" class=\"iframe\" src=\"\/quiz\/?quiz=right-join\" name=\"quiz\" width=\"600\" height=\"700\"><\/iframe><\/p>\r\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"314\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Right Join\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"314\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL Right Join\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":24,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-314","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL Right Join<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL Right Join\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-10T07:57:24+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/\",\"name\":\"PostgreSQL Right Join\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/x-table.svg\",\"datePublished\":\"2024-11-25T09:12:18+00:00\",\"dateModified\":\"2025-02-10T07:57:24+00:00\",\"description\":\"In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/x-table.svg\",\"contentUrl\":\"https:\\\/\\\/www.pgtutorial.com\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/x-table.svg\",\"caption\":\"x table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-tutorial\\\/postgresql-right-join\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Tutorial\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL Right Join\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL Right Join","description":"In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL Right Join","og_description":"In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-02-10T07:57:24+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/","url":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/","name":"PostgreSQL Right Join","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/#primaryimage"},"image":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/x-table.svg","datePublished":"2024-11-25T09:12:18+00:00","dateModified":"2025-02-10T07:57:24+00:00","description":"In this tutorial, you will learn how to use the PostgreSQL RIGHT JOIN clause in the SELECT statement to merge rows of two tables.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/#primaryimage","url":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/x-table.svg","contentUrl":"https:\/\/www.pgtutorial.com\/wp-content\/uploads\/2025\/02\/x-table.svg","caption":"x table"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-right-join\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Tutorial","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL Right Join"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=314"}],"version-history":[{"count":11,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/314\/revisions"}],"predecessor-version":[{"id":1977,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/314\/revisions\/1977"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}