結果圖:
index_col之前是空值。
現在有乙個需求,根據staraircraft_id進行分組。
同乙個staraircraft_id下,對index_col從0開始排序賦值。
首先,需要進行排序。
select
id,staraircraft_id,
ifrom
(select
staraircraft_id,
id,@i:=if(@gen=staraircraft_id,@i+1,0) i,
@gen:=staraircraft_id
from gacs_staraircraftpic,(select @i:=-1,@gen:=null) temp
order by id, staraircraft_id asc) b
這樣就可以分組排序
再直接進行賦值即可。
成功**:
update gacs_staraircraftpic a,
(select
id,staraircraft_id,
ifrom
(select
staraircraft_id,
id,@i:=if(@gen=staraircraft_id,@i+1,0) i,
@gen:=staraircraft_id
from gacs_staraircraftpic,(select @i:=-1,@gen:=null) temp
order by id, staraircraft_id asc
) b) cset a.index_col = c.i where a.id = c.id
python 運算 賦值 迴圈
python3 中只有乙個input python2 中的raw input與python3中的input一模一樣 python3中input輸出字串型別 int,float 數字型別 地板除 取餘數 冪函式 交叉賦值 x 11 y 22 x,y y,x 鏈式賦值 x 10 x y z 10 解壓賦...
mysql誤update資料恢復
誤update資料恢復 1。根據set值查詢日誌路徑 opt local mysql bin mysqlbinlog no defaults v v base64 output decode rows mysql bin.000002 grep b 15 myy more 2.建立文字 touch ...
mysql批量update資料優化
有一張表goods中有20w條資料,現在需要把某個欄位的值做md5加密後更新。一條一條迴圈更新效能差不說,還容易造成資料庫阻塞。set time limit 0 ini set memory limit 1g mysqli new mysqli 127.0.0.1 root root wx 3306...