IT tutorials
 
Office
 

Microsoft Access 2010 : Enhancing the Queries That You Build - Building Queries Based on Multiple Tables - Pitfalls of Multitable Queries

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Product Key Free : Microsoft Office 2019 – Serial Number
10/16/2014 9:57:15 PM

If you have properly normalized your table data, you probably want to bring the data from your tables back together by using queries. Fortunately, you can do this quite easily by using Access queries.

The query in Figure 1 joins the Customers, Orders, and Order Details tables, pulling fields from each. Notice in the figure that I have selected the ID and Company fields from the Customers table, the Order ID and Order Date fields from the Orders table, and the Unit Price and Quantity fields from the Order Details table. After you run this query, you should see the results shown in Figure 2. Notice that you get a record in the query’s result for every record in the Order Details table. In other words, there are 68 records in the Order Details table, and that’s how many records appear in the query output. By creating a multitable query, you can look at data from related tables, along with the data from the Order Details table.

Figure 1. A query joining the Customers, Orders, and Order Details tables.

Figure 2. The results of querying multiple tables.

By setting up relationships between tables in a database, Access knows how to properly join them in the queries that you build.


To remove a table from a query, you click anywhere on the table in the top half of the query design grid and then press the Delete key. You can add tables to the query at any time by clicking the Show Table button on the toolbar. If you prefer, you can select the Database window and then click and drag tables directly from the Database window to the top half of the query design grid.


Pitfalls of Multitable Queries

You should be aware of some pitfalls of multitable queries: They involve updating and which records you see in the query output.

It’s important to remember that you cannot update certain fields in a multitable query. You cannot update the join fields on the “one” side of a one-to-many relationship (unless you’ve activated the Cascade Update Referential Integrity feature). You also can’t update the join field on the “many” side of a relationship after you’ve updated data on the “one” side. More importantly, which fields you can update, and the consequences of updating them, might surprise you. If you update the fields on the “one” side of a one-to-many relationship, you must be aware of that change’s impact. You’re actually updating that record in the original table on the “one” side of the relationship, and several records on the “many” side of the relationship may be affected.

For example, Figure 3 shows the result of a query based on the Customers, Orders, and Order Details tables. I have changed Company D to InfoTech Services Group on a specific record of the query output. You might expect this change to affect only that specific order detail item. However, pressing the down-arrow key to move off the record shows that all records associated with Company D are changed (see Figure 4). This happens because all the orders for Company D were actually getting their information from one record in the Customers table—the record for ID 12—and that is the record I modified while viewing the query result.

Figure 3. Changing a record on the “one” side of a one-to-many relationship.

Figure 4. The result of changing a record on the “one” side of a one-to-many relationship.

The second pitfall of multitable queries has to do with figuring out which records result from a multitable query. So far, you have learned how to build only inner joins. You need to understand that the query output contains only customers who have orders and orders that have order details. This means that not all the customers or orders might be listed.

 
Others
 
- Microsoft Access 2010 : Relating the Information in Your Database - Establishing Referential Integrity
- Microsoft Project 2010 : Project on the Internet (part 5) - Integrating Project and Outlook - Routing a Project file to several recipients
- Microsoft Project 2010 : Project on the Internet (part 4) - Integrating Project and Outlook - Sending Project Information to Others
- Microsoft Project 2010 : Project on the Internet (part 3) - Integrating Project and Outlook - Importing Tasks from Outlook, Copying Tasks from an Email
- Microsoft Project 2010 : Project on the Internet (part 2) - Hyperlinking to Information - Creating a Hyperlink to a Location in the Project File
- Microsoft Project 2010 : Project on the Internet (part 1) - Hyperlinking to Information - Creating a Hyperlink to a File or Web Page
- Microsoft Word 2010 : Creating an Index (part 2) - Adding an Index to a Document - Generating an Index
- Microsoft Word 2010 : Creating an Index (part 1) - Adding an Index to a Document - Marking an Index Entry
- Microsoft Word 2010 : Creating a Table of Contents (part 2) - Adding a TOC to a Document - Inserting a Customized Table of Contents
- Microsoft Word 2010 : Creating a Table of Contents (part 1) - Adding a TOC to a Document - Inserting an Automatic Table of Contents
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us