Results 1 to 4 of 4

Thread: Query Results to a View

  1. #1
    Join Date
    Apr 2003
    Posts
    2

    Query Results to a View

    I have a table in a database that has very old and not very relational and I want to create a quick view to show the information in a better way. Let's say that the table has 4 fields : id , child1, child2, child3. I want to create a view from this table that will show two fields : id and child. So, my table currently looks like this:

    id child1 child2 child3

    1 sam bob chris

    and i would like it like this......

    id child

    1 sam

    1 bob

    1 chris

    Can anybody help me? Thanks in advance,

    Bob

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    How about this

    select id, child1
    from table1
    union all
    select id, child2
    from table1
    union all
    select id, child3
    from table1
    order by id

  3. #3
    Join Date
    Feb 2003
    Posts
    1,048
    If you're going to make a view of it, you'll either have to leave off the Order By clause or use top in your Select clause.

    select Top 100 Percent id, child1
    from table1
    union all
    select Top 100 Percent id, child2
    from table1
    union all
    select Top 100 Percent id, child3
    from table1
    order by id

  4. #4
    Join Date
    Apr 2003
    Posts
    2
    thank you both for your help.....worked well.

Posting Permissions

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