Results 1 to 3 of 3

Thread: Help with SQL

  1. #1
    Join Date
    Sep 2003
    Posts
    212

    Exclamation Unanswered: Help with SQL

    I have a table with columsn employee number, col1, col2, col3, col4, col5. Call this table 'OLDTABLE'
    eg of a record:

    Employee number | Col1 | Col2 | Col3 | Col4 | Col5
    -------------------------------------------------
    123455 x y z a b

    Call this new table 'NEWTABLE'. I have to tranfer the data from the above table in a new one that shud look like employee number, col. the above example shud look like:

    Employee number | Col
    -----------------------
    123455 x
    123455 y
    123455 z
    123455 a
    123455 b


    I was looking for a SQL for such a task.

    Thanks
    Last edited by vmlal; 08-06-04 at 13:02.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    INSERT INTO NEW
    SELECT EmpId, Col1
    FROM OLD
    UNION ALL
    SELECT EmpId, Col2
    FROM OLD
    UNION ALL
    SELECT EmpId, Col3
    FROM OLD
    UNION ALL
    SELECT EmpId, Col4
    FROM OLD
    UNION ALL
    SELECT EmpId, Col5
    FROM OLD
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Sep 2003
    Posts
    212
    thanks great brett

Posting Permissions

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