View Single Post

  #1 (permalink)  
Old 07-23-2007
P.A.
 
Posts: n/a
Default How to combine "regular" fields and fields with references in one row?

Hello,

I have a table with staff data, containing the usual id, name, address,
etc. Moreover there are some fields (e.g. for nationality, rel.
denomination, title, function) which hold integer or two-character indices
rather than the actual value. The actual values are contained in separate
tables. I do this for ease and safety of input checking in php. If the
data of a particular staff member is to be reported, I would like to have
a single query for the whole row, including the referenced values instead
of the indices itself.

Example:

table staff(staff_id, staff_name, staff_title, staff_nat,
staff_function,...);
entry: (23, Wilcox, 002, 017, SU, ...);

table titles(title_id, title);
entry: (002, Dr.);

table nats(nat_id, nat);
entry: (017, Bahamas);

table funcs(func_id, func);
entry: (SU, Surgeon);

and so on...

How could I query the row from the staff table, replacing the indices by
the referenced values?

I tried it with the UNION operator, but this gives a columns of results,
not a row, if I'm not mistaken.

Any hint is very much appreciated!

Thanks!

Pascal.


--
Reply With Quote