请我看看这个存储过程哪出错了?

来源:百度知道 编辑:UC知道 时间:2024/05/29 23:00:19
有email表:
id email price infor news

if(select price,infor,news from email where price=@price and infor=@infoe and news=@news)>0
update email set price=null,infoe=null,news=null where email=@email

我说明下我的目的:首先,我从email表中查询price,infor,news三个字段是否有数据,如果有数据,那么我将有数据的字段修改为空!
查询哪个字段有值就把哪个字段置为空!
那么怎么把查询出来与表中对应的置为空啊?

谢谢各位!我做出来了```还成功了!哈哈``还是谢谢各位了``我写的存储过程:
create proc del_email
@email nvarchar(20),
@price nvarchar(20),
@infor nvarchar(20),
@news nvarchar(20)

as
begin
if(select count(price) from user_email where price=@price)>0
update user_email set price=null where email=@email
if(select count(infor) from user_email where infor=@infor)>0
update user_email set infor=null where email=@email
if(select count(news) from user_email where infor=@infor)>0
update user_email set news=null where email=@email
end
GO

是否存在应该这样写
if exsits(select price,infor,news from email where price=@price and infor=@infoe and news=@news)
你那句不就可以的?

有个问题要搞清楚
你的意思是三个字段同时有数据时清空
还是只要有一个字段有数据就清空呀