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

FULL OUTER JOIN का उपयोग

FULL OUTER JOIN दोनों tables से सारी rows रखता है, जहाँ हो सके वहाँ match करते हुए और बाकी जगह NULL इस्तेमाल करते हुए।

In this page:

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

FULL OUTER JOIN

यह LEFT और RIGHT JOIN results combine करता है: matched rows एक बार appear होती हैं, unmatched left rows में NULL right columns होते हैं और unmatched right rows में NULL left columns होते हैं।

यह दो data sets reconcile करने के लिए useful है। PostgreSQL इसे directly support करता है; older SQLite नहीं करता।

Note: दो tables के बीच differences ढूंढने के लिए FULL OUTER JOIN handy है।

उदाहरण: FULL OUTER JOIN

bash
shop=# SELECT a.id AS in_a, b.id AS in_b
shop-# FROM table_a a FULL OUTER JOIN table_b b ON a.id = b.id
shop-# ORDER BY COALESCE(a.id, b.id);
 in_a | in_b
------+------
    1 |
    2 |    2
    3 |    3
      |    4

⚠️ 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. यह उम्मीद करना कि यह CROSS JOIN जैसा है
  2. दोनों sides पर NULLs भूल जाना
  3. जब LEFT JOIN काफी हो इसे इस्तेमाल करना
चैप्टर सारांश
  • दोनों sides से unmatched rows रखता है
  • Missing side NULL है
  • Reconciliation के लिए अच्छा
  • PostgreSQL इसे natively support करता है
🔒

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.