O'Reilly logo

Beginning SQL Queries: From Novice to Professional, Second Edition by Clare Churcher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Clare Churcher 2016

Clare Churcher, Beginning SQL Queries, 10.1007/978-1-4842-1955-3_5

5. Self Joins

Clare Churcher

(1)Studio B Productions, Great Neck, New York, USA

When we select a subset of rows based on a condition in a WHERE clause, the condition is evaluated for each row independently. An example might be a query to find all the members who have entered tournament 36. The condition TourID = 36 can be evaluated for each row in the Entry table to achieve the required result. However, if we want to find members who have entered both tournaments 36 and 24, we cannot do this by inspecting just one row of the Entry table. We need to find two rows (or entries) for the same memberone for each of the specified tournaments. A simple WHERE clause ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required