delare dnxh int
set @dnxhselect f_name,@dnxh=@dnxh+1 as f_dnxh from tbda;我的意思是让变量每次加1如下结果:
A,1
B,2
C,3
现在出现问题是"向变量赋值的 SELECT 语句不能与数据检索操作结合使用。" 而且还出现as错误,哪位知道怎么做呀,,,,急~~~~在线等啊。
set @dnxhselect f_name,@dnxh=@dnxh+1 as f_dnxh from tbda;我的意思是让变量每次加1如下结果:
A,1
B,2
C,3
现在出现问题是"向变量赋值的 SELECT 语句不能与数据检索操作结合使用。" 而且还出现as错误,哪位知道怎么做呀,,,,急~~~~在线等啊。
insert T select 'A'
insert T select 'B'
insert T select 'C'select col1, col2=(select count(*) from T where col1<=A.col1) from T as A--result
col1 col2
---------- -----------
A 1
B 2
C 3(3 row(s) affected)