Home > Database > Mysql Tutorial > body text

How to Query Multiple Tables in an Access Database Using Inner Joins?

Linda Hamilton
Release: 2024-10-30 01:21:02
Original
658 people have browsed it

How to Query Multiple Tables in an Access Database Using Inner Joins?

Access-SQL Inner Join with Multiple Tables

To query multiple tables in an Access database, you can utilize the inner join operation, which combines rows from two or more tables based on matching values in specified columns. This is particularly useful when you need to obtain data from different tables that are related to each other.

As mentioned in the question, you have five tables: tblOjt, tblStudent, tblCourse, tblCompany, and tblAddressee. To retrieve the desired values from these tables, an inner join query can be written as follows:

SELECT
    tblOjt.ID,
    tblStudent.LastName,
    tblStudent.FirstName,
    tblStudent.MiddleName,
    tblCourse.CourseAlias,
    tblCompany.CompanyName,
    tblAddressee.AddresseeName,
    tblOjt.DateAdded,
    tblOjt.DateStarted,
    tblOjt.DateEnded,
    tblOjt.OjtHours
FROM
    tblOjt
INNER JOIN
    tblStudent ON tblOjt.StudentID = tblStudent.ID
INNER JOIN
    tblCourse ON tblOjt.CourseID = tblCourse.ID
INNER JOIN
    tblCompany ON tblOjt.CompanyID = tblCompany.ID
INNER JOIN
    tblAddressee ON tblOjt.AddresseeID = tblAddressee.ID;
Copy after login

In this query, the first inner join connects tblOjt with tblStudent based on the StudentID column, while the second inner join links tblOjt with tblCourse through the CourseID column. Similarly, the third and fourth inner joins associate tblOjt with tblCompany and tblAddressee, respectively.

This syntax is specific to Access-SQL. While other SQL implementations may have different join syntax, the concept of inner join remains the same.

The above is the detailed content of How to Query Multiple Tables in an Access Database Using Inner Joins?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!