← Back to PostgreSQL Course | Chapter 6: Joins | Lesson 3 of 7

RIGHT JOIN का उपयोग

RIGHT JOIN right table से हर row रखता है और जब कोई match न हो left side को NULL से भरता है।

In this page:

  1. RIGHT JOIN
Syntax
sql
SELECT columns
FROM table1
RIGHT JOIN table2 ON table1.key = table2.key;

RIGHT JOIN

यह LEFT JOIN का mirror image है, और table order swap करना एक को दूसरे में बदल देता है, इसलिए ज़्यादातर developers सिर्फ LEFT JOIN इस्तेमाल करते हैं। RIGHT JOIN PostgreSQL से पूरी तरह supported है।

Older SQLite versions (site editor के पीछे वाला समेत) इसे support नहीं करते, इसलिए यह psql में दिखाया गया है।

Note: कोई भी RIGHT JOIN tables swap करके एक LEFT JOIN में फिर से लिखा जा सकता है।

उदाहरण: RIGHT JOIN

bash
shop=# SELECT c.name, o.id AS order_id
shop-# FROM customers c RIGHT JOIN orders o ON o.customer_id = c.id
shop-# ORDER BY o.id;
 name | order_id
------+----------
 Ada  |       10
 Ada  |       11
 Bob  |       12
 (unknown customer_id 99 shows as an empty name)

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. confusingly left और right joins mix करना
  2. ON conditions swap करना भूल जाना
  3. यह मान लेना कि सारे databases इसे support करते हैं
चैप्टर सारांश
  • RIGHT JOIN सारी right rows रखता है
  • Unmatched left columns NULL हैं
  • एक swapped LEFT JOIN के बराबर है
  • Rarely ज़रूरी
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.