Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2005

    Red face Unanswered: Getting Data Out

    Hello Dear Folks,

    It is hard to explain but let me see how well I can do it.

    I have 3 tables A, B and C. A relates to B (1-to-many), B relates to C (1-to-0...more). But relating Ato C, for every row of A there will be 2 rows in C. Because of this relationship, I am not able to join all the three tables and get a single row. This results in 2 rows for each item. I would like the data from Table C as a result of the query to be side by side making it all one row. Like a horizontal join...

    Here is the query

    select ux.unit_slno, ux.catalog_no, ux.unit_status, ux.prepare_date, ux.prepared_by, mc.MAC_Addr, mc.sw_rev from unit_module_info ux, module_cfg mc, module_info mx where mx.unit_slno=ux.unit_slno AND mc.module_slno=mx.module_slno

    in the two rows that results, sw_rev represents two different things.

    Can you geniuses help me get a single row please?

    Last edited by nsarun; 09-27-05 at 13:44.

  2. #2
    Join Date
    Jun 2003
    West Palm Beach, FL


    Post example data from all 3 tables.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Apr 2002
    Toronto, Canada
    select ux.unit_slno
         , ux.catalog_no
         , ux.unit_status
         , ux.prepare_date
         , ux.prepared_by
         , mc.MAC_Addr
         , group_concat(mc.sw_rev) as sw_revs
      from unit_module_info ux
      join module_info mx 
        on ux.unit_slno = mx.unit_slno 
    left outer
      join module_cfg mc
        on mx.module_slno = mc.module_slno
        by ux.unit_slno
         , ux.catalog_no
         , ux.unit_status
         , ux.prepare_date
         , ux.prepared_by
         , mc.MAC_Addr
    Last edited by r937; 09-28-05 at 08:32. | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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