Replacing, linking, relationships, not sure what... help :-)

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Can anyone help me with this?

In my database I have two tables:


"Distances"

| ID | FROM | TO | DISTANCE |
|---------------------------|
| 1 | 3 | 13 | 1679 |
| 2 | 3 |160 | 261 |
| 3 | 4 | 52 | 4968 |
| 4 | 4 | 7 | 673 |
| 5 | X | XX | XXXX |
| 6 | Y | YY | YYYY |


"Names"

| ID | FOO | NAME | BAR |
|------------------------------|
| 1 | ZX | ANTWERP | QWE |
| 2 | CV | OSLO | RTY |
| 3 | BN | COPENHAGEN | UIO |
| 4 | ML | HOUSTON | PAS |
| 5 | KJ | TAMPICO | DFG |
| 6 | HG | CABEDELO | HJK |


In the table "Distances", you see the rows FROM and TO,
Those number symbolizes the ID in the table "Names".
Ex. FROM 2 TO 6 would be the same as FROM OSLO TO CABEDELO.

Would it be possible to make a table or Query which replaces
the numbers in FROM and TO with the correct names under NAME
in the "Names" table?


Thanks :)
 
You sure can do this. In fact, this is what sql is designed to do.

Just drop in your distances table into the query builder.

Then, just drop in the Names table. Draw a join line from the "from" field
to the Names field. (make sure you make this a left join). Now, drop in the
names table again. Now, simply draw a join line from the "to" field to the
names table again (of course, the line is joined to the id field). Again,
make sure the join is a left join (just double click on the join line, slect
the option to join any from the distances, and some from the names table --
you can't use the option where both are equal).

Anytime you have a bunch of lookup id as yours, you can build a query. In
fact, you can just continue dropping in as many related tables as you need.
 
Back
Top