SQL Joins Explained: INNER, LEFT, RIGHT, and FULL, With Examples
The monthly report was wrong, and nobody could say why. The shop had four customers and four orders, but the revenue report listed only two customers, while the customer list showed two people who had apparently never bought anything. The difference was a single word: INNER in one place, LEFT in the other. That word decides which rows survive, and getting it wrong raises no error, only a tidy, plausible, wrong answer. A join combines rows from two tables by matching values, usually a foreign key with a primary key. INNER keeps only rows that match on both sides. LEFT keeps every row from the left table, with blanks where nothing matches. RIGHT mirrors that, and FULL keeps everything. What I would check before using it My judgement, from years of reading other people's queries, is that the join type is a business decision wearing a syntax costume, so the first question is always what the reader of the result needs to see. A revenue report should use an INNER JOIN, because an orde...