mysql, 一个表里有 10条记录,有一个rowNum列,记录的是行号,
0
1
9
如果把第3,5,7条记录删掉, 我希望删完之后能这样
0
1
2
3
4
5
6而不是
0
1
3
5
7
8
9请问咋整。
0
1
9
如果把第3,5,7条记录删掉, 我希望删完之后能这样
0
1
2
3
4
5
6而不是
0
1
3
5
7
8
9请问咋整。
解决方案 »
- 关于mysql中的外键和索引
- 【SQL语句】怎么根据需求除去某列重复结果
- 求sql语句,在线等
- mysql 判断替换字符串
- linux下安装mysql插件 出现ERROR 1146 (42S02): Table 'mysql.plugin' doesn't exist
- mysql 的字符集是latin1,但还是可以存储中文,而且不会乱码?实在不知道其中的原由..有高手可以解答一下吗?
- mysql论坛
- 哪里有MySQL的源代码下载啊?
- 郁闷啊郁闷, mysql数据库的或者是php程序的问题,搞不清啊。。。
- 多个表关联,使用左连接。一直迷惑这个概念,求高手帮我。
- 问一个很蠢的问题,mysqlimport怎么用
- 存储过程中的游标
MySQL中的ROWNUM的实现
1、 可以用JOIN实现2、用变量累加得到行号
+----+
| id |
+----+
| 0 |
| 1 |
| 2 |
| 4 |
| 6 |
| 8 |
| 9 |
+----+
7 rows in set (0.00 sec)mysql> update tx t1,
-> (select id,(select count(*) from tx where id<t.id) as newid from tx t) t2
-> set t1.id=t2.newid
-> where t1.id=t2.id;
Query OK, 4 rows affected (0.06 sec)
Rows matched: 7 Changed: 4 Warnings: 0mysql> select * from tx;
+----+
| id |
+----+
| 0 |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
+----+
7 rows in set (0.00 sec)mysql>
select id,@ee:=@ee+1 from ttqorselect a.id,count(b.id) from ttq a
left join ttq b on a.id>b.id
group by a.id
(select a.id,count(b.id) as id1 from ttq a
left join ttq b on a.id>b.id
group by a.id) b1
set a1.id=b1.id1
where a1.id=b1.id