473,654 Members | 3,071 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using INNER JOIN with 3 tables

I have an application that uses an Access database to
gather information on students' test scores. In the
database there are three tables which are joined by one-
to-many relationships: Students, Subjects, and Tests. I
am trying to create a query that joins these three tables
and show all the subjects for only one student, and all
the tests taken in each of those subjects. This is the
query I have entered in the Query Builder:

SELECT Subjects.Subjec tName, Subjects.Subjec tID,
Tests.Score
FROM Students INNER JOIN
Subjects ON Students.Studen tID =
Subjects.Studen tID INNER JOIN
Tests ON Subjects.Subjec tID =
Tests.SubjectID
WHERE (Students.Surna me = '<Student'sSurn ame>') AND
(Students.First Name = '<Student'sFirs tName>')

(In the WHERE clause I have entered a specific student's
first name and surname.)

And I get the following error message:

Syntax error (missing operator) in query
expression 'Students.Stude ntID = Subjects.Studen tID INNER
JOIN PACEInfo ON Subjects.Subjec tID = PACEInfo.Subjec tID'.

If I leave out the second INNER JOIN clause, everything
works fine. Is it possible to join three tables, and if
so, where am I going wrong?
Nov 20 '05 #1
4 23892
It is possible.
You have a syntax problem.
Build the same query in the Access query window with 3 joined tables and
then view the SQL.
--
Joe Fallon

"Nathan" <an*******@disc ussions.microso ft.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
I have an application that uses an Access database to
gather information on students' test scores. In the
database there are three tables which are joined by one-
to-many relationships: Students, Subjects, and Tests. I
am trying to create a query that joins these three tables
and show all the subjects for only one student, and all
the tests taken in each of those subjects. This is the
query I have entered in the Query Builder:

SELECT Subjects.Subjec tName, Subjects.Subjec tID,
Tests.Score
FROM Students INNER JOIN
Subjects ON Students.Studen tID =
Subjects.Studen tID INNER JOIN
Tests ON Subjects.Subjec tID =
Tests.SubjectID
WHERE (Students.Surna me = '<Student'sSurn ame>') AND
(Students.First Name = '<Student'sFirs tName>')

(In the WHERE clause I have entered a specific student's
first name and surname.)

And I get the following error message:

Syntax error (missing operator) in query
expression 'Students.Stude ntID = Subjects.Studen tID INNER
JOIN PACEInfo ON Subjects.Subjec tID = PACEInfo.Subjec tID'.

If I leave out the second INNER JOIN clause, everything
works fine. Is it possible to join three tables, and if
so, where am I going wrong?

Nov 20 '05 #2
Where's the "PACEInfo" coming from in your error?
Nov 20 '05 #3
Hi,

You need to put the first inner join in brackets ().

SELECT Subjects.Subjec tName, Subjects.Subjec tID, Tests.Score
FROM ( Students INNER JOIN Subjects ON Students.Studen tID =
Subjects.Studen tID) INNER JOIN Tests ON Subjects.Subjec tID = Tests.SubjectID
WHERE (Students.Surna me = '<Student'sSurn ame>') AND (Students.First Name
= '<Student'sFirs tName>')

Ken
----------------------
"Nathan" <an*******@disc ussions.microso ft.com> wrote in message
news:00******** *************** *****@phx.gbl.. .
I have an application that uses an Access database to
gather information on students' test scores. In the
database there are three tables which are joined by one-
to-many relationships: Students, Subjects, and Tests. I
am trying to create a query that joins these three tables
and show all the subjects for only one student, and all
the tests taken in each of those subjects. This is the
query I have entered in the Query Builder:

SELECT Subjects.Subjec tName, Subjects.Subjec tID,
Tests.Score
FROM Students INNER JOIN
Subjects ON Students.Studen tID =
Subjects.Studen tID INNER JOIN
Tests ON Subjects.Subjec tID =
Tests.SubjectID
WHERE (Students.Surna me = '<Student'sSurn ame>') AND
(Students.First Name = '<Student'sFirs tName>')

(In the WHERE clause I have entered a specific student's
first name and surname.)

And I get the following error message:

Syntax error (missing operator) in query
expression 'Students.Stude ntID = Subjects.Studen tID INNER
JOIN PACEInfo ON Subjects.Subjec tID = PACEInfo.Subjec tID'.

If I leave out the second INNER JOIN clause, everything
works fine. Is it possible to join three tables, and if
so, where am I going wrong?

Nov 20 '05 #4
* "Nathan" <an*******@disc ussions.microso ft.com> scripsit:
I have an application that uses an Access database to
gather information on students' test scores. In the


Only FYI:

Group for ADO.NET questions:

<news://msnews.microsof t.com/microsoft.publi c.dotnet.framew ork.adonet>

Web interface:

<http://msdn.microsoft. com/newsgroups/default.asp?url =/newsgroups/loadframes.asp? icp=msdn&slcid= us&newsgroup=mi crosoft.public. dotnet.framewor k.adonet>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8946
by: Jonathan Patton | last post by:
Hi,=20 I have a query that runs in Microsoft Access against my mysql database = just fine. It is:=20 =20 UPDATE discussion_categories AS discussion_categories_1=20 INNER JOIN discussion_categories ON=20 discussion_categories_1.parent_1_text =3D discussion_categories.name=20 SET discussion_categories_1.parent_1 =3D =
0
1332
by: B. Fongo | last post by:
------=_NextPart_000_0007_01C36311.DEE8D2E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello! I ' m trying to extra some information from 2 tables using inner join,
0
1537
by: B. Fongo | last post by:
------=_NextPart_000_0011_01C36322.2FEF5DC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable It works!=20 SELECT Customers.Name, Customers.City, Orders.Product, Order.Price FROM Customers INNER JOIN Orders ON Customers.cust_id =3D Orders.cust_id WHERE cust_id =3D 2;
5
32348
by: asgars | last post by:
i have two tables, tab1 having N1 col and tab2 N2 col. now N1 is subset of N2. I need the information from tab2 (having N2) of all rows having the matching entry in N1 in tab1. For this i am using Inner Join on cols N1 and n2. But result is giving duplicate rows. Can anyone suggest how do u i remove those duplicate rows? or may be a better way to do the above work... Thanks
7
2564
by: Christian Muenscher | last post by:
Dear group! The following statement gives me a resultset containing two columns containing a PersonID: SELECT * FROM A LEFT JOIN B ON A.PersonID=B.PersonID UNION SELECT * FROM A
1
2095
by: chaitanya02 | last post by:
Hi,,, I have 2 tables in access: tblUrl (software Url, contract number- 2 columns) and tblAccContract(4 columns-accountid, contract id, contract date, email addr) I am querying these two tables using inner join. I get the result properly, but unable to retrieve the values from those tables. I think the problem is with the query I used for joining these two tables. Please check with this: The output has to be like:"Download your...
3
2359
by: chaitanya02 | last post by:
I have problem joining four tables using Inner Join in ACCESS DB, I want to join 4 tables: 1, 2, 3 , 4 ....and query data in all these to see, i get a right url associated. sql1-account id, account name sql2-account id, email id sql3-account id, contract number, maintenance start date, maintenance expiration date, download url, contact, maintenance status sq4-account name, user id, pwd first- i will check if the USER NAME and PWD I...
12
13179
by: Chamnap | last post by:
Hello, everyone I have one question about the standard join and inner join, which one is faster and more reliable? Can you recommend me to use? Please, explain me... Thanks Chamnap
4
1950
kcdoell
by: kcdoell | last post by:
Hello: I have a form that has 3 combo boxes. CboDivision cboWrkReg cboCreditReg In the Field Properties, of those combo boxes I used the “Default Value” to populate selections that were made via another form I created.
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.