Joins

A join is query that selects more than one table. Normally the tables are linked by fields that have the same meaning. The linking fields do not need to have the same names, although joins are less confusing if the do.

Suppose the Students table has a StudentId field. The TestScores table also has a StudentId field indicating the student who got a particular score. The two StudentId fields link the tables. The following query joins the two tables to select student information from the Students table plus test scores from the TestScores table:

SELECT TestNumber, LastName, FirstName, Score 
FROM Students, TestScores 
WHERE Students.StudentId = TestScores.StudentId 
ORDER BY TestNumber, LastName, FirstName, Score 

In many cases, that’s as ...

Get Visual Basic® .NET Database Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.