Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Query from a query results

    Okay let me try to explain. I have these 2 tables.

    Table: DOG_HEADER
    owner
    house_no
    street_name
    apt_no
    phone


    Table: DOG_DETAIL
    license
    expire_year
    no_year
    dog_name
    dog_breed
    House_no
    street_name
    apt_no

    One to many relation: For one DOG_HEADER many DOG_DETAILS


    I have a search form that take in the values for license, expire_year, and no_year and displays the results from the DOG_DETAL table. Now on that same page I want to diplay info about the do's owner from the DOG_HEADER table. The two tables are links via house_no, street_name, and apt_no. so when you do the original search using license, expire_year, no_years the results do contain house_no, street_name, apt_no. So without having to have another detail page how can I use the result info to query the other table and display it on the same page.
    "Knowledge Speaks But Wisdom Listens"

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think i get what you mean, but i dont quite get the relation between the tables.

    try this:

    SELECT dd.*, dh.owner, dh.phone
    FROM DOG_DETAIL as dd
    RIGHT JOIN DOG_HEADER as dh
    ON (dh.apt_no = dd.apt_no)

  • #3
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts
    So, this should query the dog_header table using the results from the search_page and display the results of the search page and the second query on the same page.

    Well the relationship that. The DOG_HEADER table has the owners information and the Dog_Detail contain the dog information. so 1 owner can have many dogs. The House_no, street_name, and apt_no make up the primary key (unique) in the table DOG_HEADER.
    "Knowledge Speaks But Wisdom Listens"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •