Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have table in sql i want to cross join or self join


SQL
Name          Value1       
jim            100           
jak            50
stiv           25 


expected result

SQL
Name value1  
Jim   100 
Jim   50
Jim   25
jack  100
jack  50
jack  25
stiv  100
stiv  50
stiv  25 


What I have tried:

still i am working on it ,and i could like know what is the best method to achieve this
Posted
Updated 17-Jul-16 21:31pm
Comments
Tomas Takac 12-Jul-16 3:10am    
What have you tried so far? Show your code.
Suvendu Shekhar Giri 12-Jul-16 3:13am    
That's pretty easy to do.. Share what have you tried so far.

SQL
SELECT        t.name, t1.value
FROM            Table_1 AS t CROSS JOIN
                         Table_1 AS t1
ORDER BY t.infoID
 
Share this answer
 
SQL
Select t1.name,t2.value from myTable t1, myTable t2
 
Share this answer
 
v3
Just write the query

SQL
SELECT  b.NAME, a.Value1
    FROM Table_1 a, Table_1 b


I assumed that your table name is Table_1

happy coding! :)
 
Share this answer
 
Comments
Anisuzzaman Sumon 20-Jul-16 9:21am    
I could not understand why did someone give me down vote?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900