我有...
id email groupid
=========================================
1 abc@def 0
2 abc@def 0
3 yyy@yyy 0
4 zzz@zzz 0
5 abc@def 0
6 abc@def 0
我想...
id email groupid
=========================================
1 abc@def 1
2 abc@def 1
3 yyy@yyy 2
4 zzz@zzz 3
5 abc@def 4
6 abc@def 4
我正在运行这个...
set @previous_email= 0;
set @row= 0;
update slcms_table a, (select if(@previous_email=email, @row:=@row+1, @row:=1) as row, @previous_email:=email, email from slcms_table order by id) aa set a.groupid = aa.row where a.email=aa.email
但这给了我...
id email groupid
=========================================
1 abc@def 1
2 abc@def 1
3 yyy@yyy 3
4 zzz@zzz 4
5 abc@def 5
6 abc@def 5
我怎样才能在 Mysql 中做我想做的事?我需要将顺序值设置为 groupid 列。