怎么样使用@@identity往别的表再插入一条数据?
INSERT INTO `5iguocms_article_20`(catid,specialid,typeid,title,titleintact,subheading,style,showcommentlink,introduce,keywords,author,copyfrom,paginationtype,maxcharperpage, hits,comments,thumb,username,addtime,editor,edittime,checker,checktime,templateid,skinid,arrposid,status,listorder,arrgroupidview,readpoint,ishtml,htmldir,prefix,urlruleid,islink,linkurl) values('43', '0', '0', '况况', '', '', '', '0', ' ', '', '', '', '2', '10000', '0', '0', 'uploadfile/2009/0728/20090728114604246.jpg', 'MELISSA', '1248752685', 'MELISSA', '1248752685', 'MELISSA', '1248752685', '0', '0', '', '3', '0', '', '0', '0', 'html', '', '0', '0', 'http://news.edutvcn.com/2009/0728/xNMDAwMDAwMDAxNA.html');
set @id = @@identity;
select @id;
set @content = select content 5iguodata_c_news where contentid=@id;
inert into a values(@id,@content);这样用途的SQL应该怎么写,紧急。
INSERT INTO `5iguocms_article_20`(catid,specialid,typeid,title,titleintact,subheading,style,showcommentlink,introduce,keywords,author,copyfrom,paginationtype,maxcharperpage, hits,comments,thumb,username,addtime,editor,edittime,checker,checktime,templateid,skinid,arrposid,status,listorder,arrgroupidview,readpoint,ishtml,htmldir,prefix,urlruleid,islink,linkurl) values('43', '0', '0', '况况', '', '', '', '0', ' ', '', '', '', '2', '10000', '0', '0', 'uploadfile/2009/0728/20090728114604246.jpg', 'MELISSA', '1248752685', 'MELISSA', '1248752685', 'MELISSA', '1248752685', '0', '0', '', '3', '0', '', '0', '0', 'html', '', '0', '0', 'http://news.edutvcn.com/2009/0728/xNMDAwMDAwMDAxNA.html');
set @id = @@identity;
select @id;
set @content = select content 5iguodata_c_news where contentid=@id;
inert into a values(@id,@content);这样用途的SQL应该怎么写,紧急。
select @id;
set @content = select content 5iguodata_c_news where contentid=@id;
inert into a values(@id,@content);红色部分本身语法不对。
实现这个功能建议改成如下
set @id = @@identity;
inert into a select contentid,content from 5iguodata_c_news where contentid=@id;
实现这个功能建议改成如下
set @id = @@identity;
insert into a select contentid,content from 5iguodata_c_news where contentid=@id;
contentid 不是来源于5iguodata_c_news ,是来源于(@@identity),这个问题现在已经不需要解决了,但是如果能弄清楚的话还是很好的。