我提出了3个问题,要求重新排列我的桌子。
SELECT @i:=0;
UPDATE imagedata SET imagedata.rank = 0;
UPDATE imagedata SET imagedata.rank = (SELECT @i:=@i+1) WHERE imagedata.kategorieID = 1;
我从上至下执行。
问题: 这样做的越少?
thx for all the feedback.. but i have a differnet Idear now: Somehow I have to "connect" the "kategorieID" with the "id(Primary key)" collumn Therefore I need to store both information into the "rank" collumn in the format like:
cxxx
c=Category Number(0 to 4) xxx = id (1 to ...n)..unique!
考试:产出:
rank
+------+
+ 1001 +
+ 1002 +
+ 1003 +
+ ... +
+ 1018 +
+ ... +
+ 2001 +
+ 2002 +
+ 1019 +
+ 1020 +
到目前为止,我也这样做:
UPDATE imagedata SET imagedata.rank = (SELECT CONCAT(kategorieID,"",LPAD(id,3, 0 )) ) WHERE id=88;
一旦“等级”填满了数据,它就给我放弃2 先令。
Therefore I have to: 1) get "rank" collumn of id_1 and id_2 2) get the substring ( xxx ) of that string exampl: ("004" .. "012") 3) exchange substrings of id_1 "rank" and id_2 "rank"
SELECT @ix1:=SUBSTRING(rank, -3) FROM imagedata WHERE id=88;
SELECT @ix2:=SUBSTRING(rank, -3) FROM imagedata WHERE id=83;
。 我知道如何做到这一点,但真心知道如何交流?