表1:
表1ID, title ,addTime表2:
表2ID, Content,表1ID想做一个存储过程,先插入标题和时间到表1,然后把内容插入到表2,并记录关联的表1的ID.

解决方案 »

  1.   

    哪位mysql的前辈把下面这个sql的存储过程改为mysql的存储过程,不胜感激!
    您只要帮我改完这个,其它的我就能举一反三啦.
    Create Procedure news_Add
    (
    @Title nvarchar(50),
    @Content ntext,
    @AddTime DateTime
    )as--把title和addtime插入表1insert into 表1(title,addtime) values(@Title,@AddTime)
    --准备获取刚插入的表1IDDECLARE @ID int
    select top 1 @ID = 表1ID from 表1 where title=@Title and addtime=@Addtime--把内容和关联的表1ID插入表2insert into 表2(Content,表1ID) values(@Content,@ID)
      

  2.   

    基本上都一样。select top 1 @ID = 表1ID from 表1 where title=@Title and addtime=@Addtime使用select ...into ...即可