Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Multiple JOINS with Access
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 03 December 2003 :  12:24:07  Show Profile  Visit D3mon's Homepage
Coming from a SQL Server background and now working with MS Access, I'm having a bit of trouble using multiple joins in my SQL statements:

SELECT Model, CategoryName, ManfName, Details
FROM tblCars
INNER JOIN tblCategory on tblCategory.CategoryID = tblCars.CategoryID
INNER JOIN tblCarManfs on tblCarManfs.CarManfID = tblCars.CarManfID
ORDER BY Model asc


Can I not do this with MS Access?


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"

Edited by - ruirib on 03 December 2003 12:34:36

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 03 December 2003 :  12:35:53  Show Profile  Send ruirib a Yahoo! Message
Just use parenthesis:

SELECT Model, CategoryName, ManfName, Details
FROM (( tblCars
INNER JOIN tblCategory on tblCategory.CategoryID = tblCars.CategoryID)
INNER JOIN tblCarManfs on tblCarManfs.CarManfID = tblCars.CarManfID)
ORDER BY Model asc



Snitz 3.4 Readme | Like the support? Support Snitz too

Edited by - ruirib on 03 December 2003 12:38:43
Go to Top of Page

snaayk
Senior Member

USA
1061 Posts

Posted - 03 December 2003 :  12:42:01  Show Profile  Visit snaayk's Homepage  Send snaayk an AOL message  Send snaayk an ICQ Message  Send snaayk a Yahoo! Message
Another easy method is to do it through the Access GUI andthen view the SQL it creates. I remember going back to that while I was learing sql(as if one ever stops )
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 03 December 2003 :  13:40:07  Show Profile  Visit D3mon's Homepage
Excellent. thanks guys. I'll give it a go. Hopefully the transition between the two sets of syntax will be nice and smooth.


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 03 December 2003 :  13:46:41  Show Profile  Send ruirib a Yahoo! Message
quote:
Originally posted by D3mon

Excellent. thanks guys. I'll give it a go. Hopefully the transition between the two sets of syntax will be nice and smooth.


Most things are similar, there isn't such a big difference. Anyway, use snaayk's suggestion, it's a good way to quickly learn SQL in its Access variant.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 03 December 2003 :  16:37:30  Show Profile  Visit D3mon's Homepage
One other thing, can I use Queries in the same way as Stored Procedures like:

strSQL = "All Car Details"

Where All Car Details is the name of a query designed in the Access GUI?


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 03 December 2003 :  17:02:23  Show Profile  Send ruirib a Yahoo! Message
Yes you can. You should specify that in the rs.Open statement, though, using adCmdStoredProc instead of adCmdText.


Snitz 3.4 Readme | Like the support? Support Snitz too

Edited by - ruirib on 03 December 2003 17:06:15
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 04 December 2003 :  04:15:53  Show Profile  Visit D3mon's Homepage
I'm using code like this:

strSQL = "AllCarDetails"
Set RS = DB.Execute(strSQL)

How to add the adCmdStoredProc part to that? (Oddly, it does seem to work without it!)
At the moment, I don't have the ADO constants file included.


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"

Edited by - D3mon on 04 December 2003 04:19:09
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 04 December 2003 :  06:17:33  Show Profile  Visit D3mon's Homepage
Info on devGuru suggests this to be correct:

Const adCmdStoredProc = &H0004

strSQL = "qryAllCars"
Set objRS = objDB.Execute(strSQL, ,adCmdStoredProc)

can anyone confirm?


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 04 December 2003 :  07:10:43  Show Profile  Send ruirib a Yahoo! Message
Yes, I would say that is correct.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07