Author |
Topic |
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 06 March 2002 : 10:46:45
|
When do you join and when don't you? I am a little confused because I came accross some code in the forum and differs from what I have seen elsewhere.
The following statements get the same results (I think so...):
SELECT TBL1.FIELD1, TBL1.FIELD2, TBL1.FIELD3, TBL2.FIELD1, TBL2.FIELD2 FROM TBL1, TBL2 WHERE TBL2.FIELD3 = TBL1.FIELD3
SELECT TBL1.FIELD1, TBL1.FIELD2, TBL1.FIELD3, TBL2.FIELD1, TBL2.FIELD2 FROM TBL2 INNER JOIN TBL1 ON TBL2.FIELD3 = TBL1.FIELD3
So, the question is, which do you use? Obviously, if you're using a variable off of the querystring, you don't have a choice. But if your data is from 2 tables which is best?
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 06 March 2002 : 10:52:59
|
The top version is usually used in the fourm. It might be because it makes more logical since and it might be that is it more corss-database complient.
Joins can get confusing. . . but that makes them all the more fun
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
davemaxwell
Access 2000 Support Moderator
USA
3020 Posts |
Posted - 06 March 2002 : 11:09:46
|
Those are actually both JOINS. One is just the ANSI standard and the other is not (don't remember which is which).
It's a matter of taste personally. I find the first one much easier to read.
Dave Maxwell -------------- Proud to be a "World Class" Knucklehead |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 06 March 2002 : 11:14:05
|
Joins are confusing! And besides, the two statements are essentially equivalent. Doing a "WHERE blah = ugh" is an implied join.
Nikkol |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 06 March 2002 : 11:22:03
|
Its still considered a join, just using different logic.
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
snaayk
Senior Member
USA
1061 Posts |
Posted - 06 March 2002 : 11:44:57
|
aahhh, I see. Implying is sometimes better than just saying it [;] I agree, the top one is more simple, a lot easier to read than the non-implied join.
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 06 March 2002 : 13:46:49
|
All the previous is true because you have a inner join. If it was an outer join, it would be a different scenario. You couldn't use a WHERE clause to do it...
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 06 March 2002 : 18:26:23
|
Really? I just know how to make a join, not all the terminology and what the differences are. Please explain inner vs outer join, left vs right join. *learning oppertunity*
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Doug G
Support Moderator
USA
6493 Posts |
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
|
Topic |
|