If i have a table that looks like
num
1
2
3
4
5
6
7
8
9
And i want to display the same table in two columns
SELECT t1.num, t2.num FROM (SELECT * FROM x) AS t1, (SELECT * FROM x) AS t2
So the result set looks like
num
1,1
2,2
3,3
4,4
5,5
6,6
7,7
8,8
9,9
How would i go about doing this in MySQL
EDIT
Sorry i didnt want to make things complex to start with: But here is what im actually trying to do
To clarify a little more, What im actually trying to do is
num
1,2
2,3
3,4
4,5
5,6
6,7
7,8
8,9
what i want to be able to do further:
SELECT t2.num - t1.num FROM ....
Note that the above query will return all 1s but the values in my database are different to what are displayed above
Thanks in Advance
I don’t understand why you don’t just do something more simple:
Or if you really want it as a string:
If you want to select the table twice you could join the table with itself, but I can’t see why you would want to do this:
It would make more sense if you needed fields from different rows, e.g. ‘1,2’, ‘2,3’, etc… Perhaps you have oversimplified things when you made your question? Are you just trying to learn how to use the join syntax?