simple question!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a (simple) question as to how tables relate:
Lets say i have made to tables:
Colors:
Color_id(number) Color(text)
1 White
2 Black
3 Red

and

Cars:
Owner_id(number) Owner(text) Color_id(number)
1 Bob 3
2 Lisa 1
3 John 1

Next i make a report on the table Cars, in wich i group by Color and list
the names, e.i.
1
John
Lisa
3
Bob

Now, instead of showing the Color_id, i want it to display the Color, that is:
White
John
Lisa
Red
Bob

How do i do this? It is important that the information stored in the table
Cars is the Color_id, not just Color.
another way to formulate this (i think) is: Given a secondary key in one
table, how do you refer to a given field in the related table wherein this
key is primary?
 
I have a (simple) question as to how tables relate:
Next i make a report on the table Cars, in wich i group by Color and list
the names, e.i.

Make a query like so:

SELECT Cars.Owner_id, Cars.Owner, Color.Color
FROM Cars LEFT JOIN Color ON Cars.Color_id = Color.Color_id;

Then base the report on the query and do the sorting/grouping in the report.

Tom Lake.
 
SELECT Colors.Color, Cars.Owne
FROM Colors INNER JOIN Cars ON Colors.Color_ID = Cars.Color_ID

Basically, you just have to bring in both tables and specify whic
fields are related to each other (Colors.Color_ID and Cars.Color_ID)
Then, just display the fields you want

This will retur
White Lis
White Joh
Red Bo
 
Back
Top