August 26th, 2003, 01:48 PM
HELP joining two tables
I am creating a view that displays service codes and descriptions. I have two tables. Table 1 has service codes and table 2 has service code and description.
all of the fields in table 1 are dependant on table 2.
How can I join all three service codes from table 1 to table 2 to get each individual service code description?
August 26th, 2003, 03:36 PM
how about you explain a little better and give us a few real values. Table one sounds completely erroneous if it's redundant in the primary key in table two.
this is what i'm pictureing
are certain descriptions missing where you have something in table 1 but nothing in table 2 and you want to know how to join these tables keeping the values in table 1 even though you have no entry in 2? Perhaps i just didn't understand your schema explanation....
table 1 table 2
servcode servcode desc
123 123 blah
463 463 blah
987 967 blah
August 26th, 2003, 03:38 PM
Include the same description table three times. You can do this by using aliases, like this:
FROM table1 a, table2 b, table2 c, table2 d
August 26th, 2003, 03:44 PM
table 1 contains three different service code fields.
exterior_service_code1 <--- contains 100 distinct codes
interior_service_code2 <--- contains 50 distinct codes
misc_service_code3 <--- contains 25 distinct codes
table 2 contains all of the descriptions for each code
service_code <--------contains all codes (exterior_service_code1, interior_service_code2 and misc_service_code3) <--- contains 175 distinct codes
serivice_description <-- contains 175 distinct descriptions
so the three fields get their description from table 2
does this help?
Last edited by method; August 26th, 2003 at 03:52 PM.
August 27th, 2003, 08:32 AM