首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

看看这句存储过程错在哪.解决思路

2012-02-21 
看看这句存储过程错在哪...是语法错误,应该怎么改?insertintoArticle(father_id,author_id,title,text)val

看看这句存储过程错在哪...
是语法错误,应该怎么改?

insert     into     Article   (father_id,   author_id,   title,   text)  
values
(@father_id,   select     id       from     userinfo     where     username=@username,   @title,   @text)


谢谢~


[解决办法]
declare @authorID int

select @authorID = id from userinfo where username=@username

insert into Article (father_id, author_id, title, text)
values
(@father_id, @authorID, @title, @text)
[解决办法]
insert into Article (father_id, author_id, title, text)
values
(@father_id, select id from userinfo where username=@username, @title, @text)

SQL语法错误,不能这样用
可改为

insert into Article select @father_id, id , @title, @text from userinfo where username=@username

热点排行
Bad Request.