UPDATE ProjectInfo
SET Sort=row_number() over (order by ProjectID)
WHERE ProjectID in(1,2,3,4,5,6)
解决方案 »
- mysql数据库使用mysqlbinlog工具恢复出错 非常急...求高手帮助
- 请问:MySQL存储过程能不能输出文件?
- ERROR 1206 (HY000): The total number of locks exceeds the lock table size
- 求在XP下怎样做Postgresql的数据备份?紧急求助。。
- 请问mysql数据库有没有登录的用户名和密码啊?
- SELECT in a stored procedure must have INTO这句话的意思是什么?
- 如何在RedHat 8.0上安装mysql的c++ API包mysql++?
- 求一条SQL语句
- MySQL Migration Toolkit出问题
- 如何将Mysql表中的一条记录分为多条记录
- MYSQL语法错误
- mysql怎么才能批量修改。
;with cte as
(
select ProjectID,sort,rid=row_number() over (order by ProjectID)
)update ProjectInfo a
set a.sort = b.rid
from cte b
where a.ProjectID = b.ProjectID
SELECT projectID,ROW_NUMBER() OVER(ORDER BY projectID) ID FROM ProjectInfo
)T
WHERE ProjectInfo.projectID=T.projectID
(select (@rank:=@rank+1) rank, projectId from(
select @rank:=0, projectId from tableName order by projectId) tmp) tmp2
set tableName.sort = tmp2.rank where tableName.projectId = tmp2.projectId
不行的报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select (@rank:=@rank+1) rank,ProjectId FROM(select @rank:=0,ProjectId from Proj' at line 1
set Sort=(select count(*) from ProjectInfo where projectID<=v.projectID)
where ProjectID in(1,2,3,4,5,6)