SQL - re-arrange a table via query

Posted by abelenky on Stack Overflow See other posts from Stack Overflow or by abelenky
Published on 2010-05-04T22:49:27Z Indexed on 2010/05/04 22:58 UTC
Read the original article Hit count: 468

Filed under:
|
|

I have a poorly designed table that I inherited. It looks like:

    User  Field   Value
    -------------------
    1      name   Aaron
    1      email  [email protected]
    1      phone  800-555-4545
    2      name   Mike
    2      email  [email protected]
    2      phone  777-123-4567
    (etc, etc)

I would love to extract this data via a query in the more sensible format:

User  Name   Email              Phone
-------------------------------------------
1     Aaron  [email protected]  800-555-4545
2     Mike   [email protected]     777-123-4567

I'm a SQL novice, but have tried several queries with variations of Group By, all without anything even close to success.

Is there a SQL technique to make this easy?

© Stack Overflow or respective owner

Related posts about sql

Related posts about query