• gregorykearney (9/3/2013)


    table gennum

    tollnum, n1, n2, n3

    800123, 1234, 1235, 1236

    999123, 9876, 9875, 9874

    I want to my data to look like:

    tollnum,code

    800123, 1234

    800123, 1235

    800123, 1236

    999123, 9876

    999123, 9875

    999123, 9874

    How do I convert column data into row data?

    Or a simple UNION ALL

    SELECT * FROM (

    SELECT tollnum, n1 as N FROM gennum

    UNION ALL

    SELECT tollnum, n2 FROM lixo

    UNION ALL

    SELECT tollnum, n3 FROM lixo

    ) t

    ORDER BY tollnum

    Either way it works...



    If you need to work better, try working less...