How do I join 1 column data with another column in SQL

enter image description here

I have 2 columns with Data in same table. How do I do a join to get the following result as attached in the image

2 answers

  • answered 2018-11-07 22:29 Aaron Dietz

    You're looking for a CROSS JOIN

    SELECT t.Col1, t2.Col2
    FROM yourTable t
    CROSS JOIN yourTable t2
    

  • answered 2018-11-08 03:29 gbouras

    It's similar in Oracle - although I would probably label the 4 columns left to right as: t(col1, col2, col3, col4)

    Then we would have:

    SELECT t1.col1, t2.col4 --or any column using t2.*
    FROM yourtab t1, youtab t2
    WHERE t1.col1 = t2.col3;