Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple table query 1

Status
Not open for further replies.

jiminy

Technical User
Jan 26, 2002
30
US
I would like to query two tables of different structures. My goal is to create a new table with select fields from each table. Pdox says the query appears to be asking two different questions. Does it mean that the tables have to be the same structure? What is the point of having multiple-table queries using only one structure. If I wanted to do that I would start by putting all the info into the same table.
 
jiminy,

No, you don't need to put data in tables with the same structure. As you pointed out, that would defeat the purpose of an RDBMS in the first place.

Most likely, the message you're getting indicates that you've not joined the two tables together using example elements, for example, consider the following query (which should generate the same error):

Code:
Query

   :WORK:CUSTOMER.DB | CustomerNo |
               Check |            |

   :WORK:ORDERS.DB | CustomerNo |
             Check |            |

EndQuery

There are probably one or more fields with values common to both tables, e.g. one links ORDERS to CUSTOMERS by storing a CustomerNo field in both tables.

To run multi-table QBE queries, you indicate this common field using example elements, as shown in the following example:

Code:
Query

   :WORK:CUSTOMER.DB | CustomerNo |
               Check | _custno    |

   :WORK:ORDERS.DB | CustomerNo |
             Check | _custno    |

EndQuery

Once you do that, you should be able to run your query.

You can place example elements in one of two ways:

1. Click the Join Tables button (I believe that's the name of it, but I mi8ght be mistaken) and then click the two common fields. This places example elements named Join1, Join2, and so on.

2. Move focus to one of the common field, press F5] and then type a single word name, e.g. custno. Repeat the same process for the second common field.

In both cases, you should see red labels appears in your query images. You need two such images to sucessfully join the tables.

If there's more than one field involved in the "commonality" of the data, e.g. you're linking on a three field key, then you'll need one example element for each set of fields.
Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top