Inner Join: Definition, Example, and Uses in SQL
An inner join is a type of join operation in relational database management systems (RDBMS) that returns only the matching rows between two or more tables. It combines rows from two or more tables based on a related column between them, known as a join condition. \n\nThe result of an inner join includes only the rows where the join condition is satisfied. In other words, it returns the intersection of the records from the joined tables. \n\nHere is an example of an inner join: \n\nTable A: \nID | Name \n----|----- \n1 | John \n2 | Mary \n3 | David \n\nTable B: \nID | Age \n----|---- \n1 | 25 \n3 | 32 \n4 | 40 \n\nInner Join: \nSELECT TableA.ID, TableA.Name, TableB.Age \nFROM TableA \nINNER JOIN TableB ON TableA.ID = TableB.ID \n\nResult: \nID | Name | Age \n----|-------|---- \n1 | John | 25 \n3 | David | 32 \n\nIn this example, the inner join returns only the matching rows from Table A and Table B based on the common ID column. The row with ID 2 is excluded from the result because it does not have a matching ID in Table B. \n\nInner joins are commonly used to combine related data from multiple tables in a database query. They can be used to retrieve data that is distributed across different tables and provide a way to connect and retrieve relevant information from those tables.
原文地址: https://www.cveoy.top/t/topic/puUY 著作权归作者所有。请勿转载和采集!