Hammons Randy G SSgt 612 ACOMS/SCXX wrote:
>Unfortunately this goes well beyond the scope of my original question.
>Although the inputs that you all have provided thus far have been a very
>good read, I still don't grasp the concept of defining a relationship. Is
>it simply referring to a primary key in a field other than the one where the
>key was defined? Or is there some other way to define a key that I don't
>see? All I'm looking for is a simple example, syntax excerpt, etc...that
>shows me (only the "slow learner" level) exactly how to define a
>relationship.
>
>
In InnoDB tables, there is a syntax for defining "foreign keys" (look it
up on mysql.com/doc), otherwise the JOIN examples you've been given is
_how_. The definition isn't explicit (unless using foreign keys), its
implicit in the use of the JOIN.
SELECT * FROM a
LEFT JOIN b ON b.primary_key = a.foreign_key_b
LEFT JOIN c ON c.primary_key = b.foreign_key_c
... the foreign_key_x values are simply values that match those
available from the primary_keys they reference (hopefully all indexed).
--
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock