if exists (select * from table where id=@id) update ... else insert...
if exists (select * from table where yonghuming=@yonghuming) begin //update end else begin //insert end
根据用户名查询积分表select count(*) from table where username = 用户名; 对这个结果进行判断
create proc updateuser( @userid int,@integral int )as declare @usercount int select @usercount=count(*) from tablename where userid=@uesrid if @usercount=0 begin insert ....... end else begin update...... end
create proc updateuser( @userid int,@integral int )as declare @usercount int select @usercount=count(*) from tablename where userid=@uesrid if @usercount=0 begin insert ....... end else begin update...... end
5楼的存储过程 基本上表达出意思了 不过不知道你的积分是否是在存在的基础上面累加的 create proc updateuser( @userid int,@integral int )as declare @usercount int select @usercount=count(*) from tablename where userid=@uesrid if @usercount=0 begin insert ....... end else begin update tablename set jifen=jifen+integral where 条件 end
update ...
else
insert...
begin
//update
end
else
begin
//insert
end
对这个结果进行判断
@userid int,@integral int
)as
declare @usercount int
select @usercount=count(*) from tablename where userid=@uesrid
if @usercount=0
begin
insert .......
end
else
begin
update......
end
@userid int,@integral int
)as
declare @usercount int
select @usercount=count(*) from tablename where userid=@uesrid
if @usercount=0
begin
insert .......
end
else
begin
update......
end
不过不知道你的积分是否是在存在的基础上面累加的
create proc updateuser(
@userid int,@integral int
)as
declare @usercount int
select @usercount=count(*) from tablename where userid=@uesrid
if @usercount=0
begin
insert .......
end
else
begin
update tablename set jifen=jifen+integral where 条件
end