शब्दकोश · डेटाबेस

SQL JOIN

A SQL JOIN combines rows from two or more tables based on a related column, letting one query return data that is stored in separate tables.

अपडेट: अक्टूबर 6, 2026

A SQL JOIN combines rows from two or more tables using a condition, usually equality between a foreign key and a primary key. It lets one query return related data that is stored separately.

Why it matters

Normalized databases split data across tables, and joins bring it back together at query time. Knowing the join types matters because they decide which rows appear. Joins on unindexed columns are a classic cause of slow queries, so join columns usually need indexes.

Example

SELECT c.name, o.id, o.total
FROM customers c
INNER JOIN orders o ON o.customer_id = c.id;

INNER JOIN returns only customers that have orders. A LEFT JOIN returns every customer, with NULL order columns for those who have none. RIGHT and FULL joins mirror and combine that behavior.

Common mistakes

  • Forgetting the ON condition, which produces a cross join with every row paired against every row.
  • Using INNER JOIN when you wanted all rows from one side, silently dropping records.
  • Filtering the right table in WHERE after a LEFT JOIN, which turns it back into an inner join. Put the condition in ON.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.