Hallo Ralf,
da Mike auf sich warten läßt und ich gerade eine Tabelle test mit zufällig vier nummerischen Werten om Attribut test (ja zufällig und halt eine Testtabelle) gefunden habe, hier ist die Query:
SET @cnt0 = 0;
SET @cnt1 = 0;
SET @cnt2 = 0;
SET @cnt3 = 0;
select lfdnr, test, lfdnr1, test1
from (select (@cnt1:=(@cnt1+1)) as lfdNr, test as test from `test` ORDER by test) a left join
(select (@cnt0:=(@cnt0+1))+2 as lfdNr1, test as test1 from `test` ORDER by test) b
on a.lfdnr=b.lfdnr1
union
select lfdnr, test, lfdnr1, test1
from (select (@cnt3:=(@cnt3+1)) as lfdNr, test as test from `test` ORDER by test) a right join
(select (@cnt2:=(@cnt2+1))+2 as lfdNr1, test as test1 from `test` ORDER by test) b
on a.lfdnr=b.lfdnr1
;
lfdnr test lfdnr1 test1
1 -3.05 NULL NULL
2 -1.56 NULL NULL
3 1.23 3 -3.05
4 3.12 4 -1.56
NULL NULL 5 1.23
NULL NULL 6 3.12
MfG Georg V.