Women in Technology

Hear us Roar



Article:
  More on JOINS
Subject:   Relationship: one to one
Date:   2001-06-04 16:22:32
From:   edith30
I'm new on sql, please explain more about how can I make the selects statement in order to output the fields from diferents tables at the same time in this kind of relationship (one to one).


Thanks.

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Relationship: one to one
    2001-06-08 06:14:43  wallinbl [View]

    If you have a Customer Table (with columns CustKey, CustFirstName, CustLastName) and an Address Table (with columns AddrKey, CustKey, AddrLine1, AddrLine2), to get all fields from both tables, you would write a query like this:

    SELECT * FROM Customer INNER JOIN Address ON
    Customer.CustKey = Address.CustKey

    This statement would return the fields: Customer.Custkey, Customer.CustFirstName, Customer.CustLastName, Address.AddrKey, Address.CustKey, Address.AddrLine1, Address.AddrLine2.