Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    2

    Unanswered: One Master and Two Detail Tables

    Dear Friends

    I have problem in MS Access Database. I have One Master Table and Two Detail Tables attached with one Primary Key I want to get information of all three tables but unable to find correct result. The following three tables:

    1. Office (O_ID Primary Key)
    2. Computer (O_ID Foreing Key)
    3. Printer (O_ID Foreing Key)

    The query i am using is:

    SELECT o.o_id, c.brand, p.model
    FROM office o, printer p, computer c
    WHERE o.o_id = c.o_id
    AND o.o_oid = p.o_id

    The computer table has two rows but in result four rows are showing. Anyone Please help me to correct the problem....

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select o.*, V.*
    from office o
    INNER JOIN
    (select c.id, c.name, 'COMPUTER' as TYPE
    from computers c
    UNION
    select p.id, p.name, 'PRINTER'
    from printers p) V ON
    o.id = V.id
    ORDER BY V.TYPE;
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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