Results 1 to 2 of 2

Thread: Need help: display joined table on listview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    328

    Need help: display joined table on listview

    SELECT a.ID, a.Name, b.ID, b.Name, b.Relationship FROM tbl_Name AS a
    INNER JOIN tbl_Dependents AS b ON b.ID=a.ID

    Example

    tbl_Name
    ID|Name----------|
    1 |James Hinrich
    2 |Larch Hamster
    3 |Johann Bach


    tbl_Dependents
    UID|ID|Name-------------|Relationship
    1--|1 |Owen Hinrich------|Son
    2--|1 |Rebecca Hinrich---|Daughter


    is it possible to display them in listview on single line?

    like this
    ID|Name---------|Dependent 1--|Relationship 1|Dependent 2-----|Relationship 2|
    1 |James Hinrich--|Owen Hinrich--|---- Son----|Rebecca Hinrich---|---Daughter

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: Need help: display joined table on listview

    It would help to know what DBMS you are using. For later versions of SQL Server you could look into UNPIVOT:

    Here are some links you converting rows to columns. Most I know of need to know how many occurrences they are dealing with:

    http://sqlserveradvisor.blogspot.com...o-columns.html

    http://www.databasejournal.com/featu...ql-server.html
    Please remember next time...elections matter!

Posting Permissions

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



Click Here to Expand Forum to Full Width