Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Now let's dig a little deeper into these multi table queries, and let's talk about understanding our query joins. Now I am going to jump out here, and notice I'll open the students table, and, and in our instructor ID column, we have eight students in here, and they're all taking lessons from all six instructors. Because if I go to the instructor table, I've got six instructors and notice their IIDs mimic their TIDs. That could change later over time, but for now, notice we have number six, Wilbur Green instructs our violins. Well we've got one person here, but let's say that they change, and they go to guitar OK? And so we really don't have anyone teaching violin anymore, right? Because that instructor doesn't have any students, instructor ID six is not here. Let's save these changes so that we're not confused, and let's go build a query. And we're going to build another multi table query, and so we'll double click instructor and students, OK? And notice if we get the, the student first name, last name, and then we get the instrument, and the instructor first and last name, and we run that. Notice everybody's there, everything's OK, and this is our student and this is our instructor. Now we may want to play with some of our names here, so we can tell that this is student and this is instructor on our columns, but we won't worry about that for right now. But this pulled, let me go back to the Query Design, and this basically pulled, if I look at my Join Type, so if I right click in the little Join or relationship line between the tables, I can get to Join Properties. Now you saw this possibly when you created the relationships, and this is different from that. This, we're not working with the table relationships, we're working with this particular join on this query, and notice this only includes rows where the join fields from both tables are equal OK? And so for that reason, let me jump back out here to the instructor table, we don't see Wilbur Green mentioned anywhere here in our query when we execute it alright? And so, what we're going to have to do here, notice if I go to SQL View, and then I execute that query, so if we click on the Run key, you can see that we don't see Wilbur over here anywhere alright? Well, there is a reason for that, and that is, let's go back to our query remember, we're only pulling where they match, and since there's no IID in the students for table to match instructor, Wilbur don't show up. But if we want to see all of our instructors, and then the students that are working with them. Let's right click, go to Join Properties, and now we're going to include all records from instructor, and only those records from students, where the join fields are equal alright? So I'll click OK, I will run that again, and now notice we have Wilbur Green showing up, but there's no student for him OK? And so you notice the little subtle nuances that you can get here in your data. And sometimes, the Join Types won't make any difference, because if you have a one to one relationship in all your data, you can't make them show any difference alright? But now, let me go back, and let's talk about one thing here. When I right click, and go to my Join Properties OK? Including the rows where the join fields from both tables are equal, this is called an Inner Join, this is by default, what's always going to be run. All records from the instructor OK? That's going to be either a left or a right, now let's go look at our query, if I right click and go to SQL View, notice instructor is the left table, and it changed that to a left join alright? Let's go back to the Design View, right click, and go to Join Properties, and say wait a minute, give me everything from the students and I click OK, and now if I go back, right click, and look at my SQL View, it's now a right join. It will return everything from the students table, and then only the ones from the instructor where the IIDs are equal between the two tables. That can get confusing alright? But that's an Inner Join, which says only pull data where I see the IID correct in both tables, and they match. A left join pulls everything from the left table, only the matches from the right. A right join pulls everything from the right table, and only the ones from the left, where it matches on the IID that we have chosen here. Now you want to go through this a time or two, and let it soak in, if it's confusing, but we can tell SQL, or we can tell Access, using SQL, when we join these two tables, exactly how we want it to treat it the data. And there can be little nuances. Now you'll run into situations in the real world, where you need to see all the records from one of the tables, that include just the matches from the other one, or you just want to see the ones where they are matching, all that. Again play with these, get you a real simple example like I've done here, and make sure this makes sense to you, but that's the different join types that you can use inside Access when you build your Join Queries.
| Course: | Microsoft Access 2010 |
| Author: | Mark Long |
| SKU: | 34224 |
| ISBN: | 1-936334-91-7 |
| Release Date: | 2011-05-12 |
| Duration: | 9 hrs / 121 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |