关于SQL语句的一个有关问题
关于SQL语句的一个问题
怎样在存储过程里写一个SQL插入语句,判断同一个用户在一天内执行两次插入后不再执行第三次?
字段名有username和datetime
------解决方案--------------------
用函数返回该用户今天发布信息的条数 小于2 就执行这条插入语句
if(function(select count(*) from User where username= name and datetime = date())< 2)
insert into User ....
乱写的是这个意思
------解决方案--------------------
怎样在存储过程里写一个SQL插入语句,判断同一个用户在一天内执行两次插入后不再执行第三次?
字段名有username和datetime
------解决方案--------------------
用函数返回该用户今天发布信息的条数 小于2 就执行这条插入语句
if(function(select count(*) from User where username= name and datetime = date())< 2)
insert into User ....
乱写的是这个意思
------解决方案--------------------
- SQL code
create proc ProcName as declare @count int select count(*) from TableName where username = '' and datediff(day,biday,getdate())=0 if(@count <= 2) begin insert into .....//插入语句 end go
------解决方案--------------------
------解决方案--------------------
create proc ProcName
@UserID varchar(20)=''
as
declare @count int
select count(*) from TableName where username =@UserID and datediff(day,biday,getdate())=0
if(@count <= 2)
begin
insert into .....//插入语句
end
go