Syntax:
SELECT K.F, F@S...... FROM T
Parameter:
T |
Table name |
K.F |
F field of the foreign key table referenced by table T’s foreign key K; K is foreign key name, or foreign key field name when it is a single-field key |
F@S |
F field of table T’s homo-dimension table S |
Example:
SELECT ID,PayDate,Amount,SupplierID.NAME FROM Payment |
Query records of the foreign key table using the syntax “foreign key field.field name” |
SELECT ID,PayDate,Amount,fk2.NAME FROM Payment |
Query records of the foreign key table using the syntax “foreign key name.field name” |
SELECT SupplierID,Name,ContactName,ContactTitle,TotalAMT@PaySupplierSum FROM Supplier |
Get TotalAMT field from Supplier table and its homo-dimension table PaySupplierSum |
SELECT ID,PayDate,Amount,SupplierID.TotalAMT@PaySupplierSum FROM Payment |
Query Payment table and get TotalAMT field from its foreign key table Supplier’s homo-dimension table PaySupplierSum |
Tips:
1) A single-field foreign key can be named after the field name, but a composite foreign key should be named specifically.
2) Tables are homo-dimension tables between each other when the relationship between their primary keys constitutes foreign key association; a table’s homo-dimension table’s homo-dimension table is also its homo-dimension table; primary keys of homo-dimension tables must have a one-to-one correspondence in order.
3) You can reference a field or one in a corresponding homo-dimension table directly, but you should reference a field in non-homo-dimension table recursively thorough the foreign key association.