我写了个sql server 存储过程
create procedure test()
begin
DECLARE @billId int ,@reivewID int ,@shopID int ,@productID int ;
select @billId = id from bill where status = 2 and ctobreview = null;
SELECT @productID = product_id from billitem where bill_id = @billId;
select @shopID = shop_id from product;
insert into ctobReview values(2,null,null,10,10,10,10,@shopID);
select @reviewID from inserted;
update bill set ctobreview_id = @reviewID where id = @billId;
end
如果改成mysql应该怎么改啊 谢谢了啊
create procedure test()
begin
DECLARE @billId int ,@reivewID int ,@shopID int ,@productID int ;
select @billId = id from bill where status = 2 and ctobreview = null;
SELECT @productID = product_id from billitem where bill_id = @billId;
select @shopID = shop_id from product;
insert into ctobReview values(2,null,null,10,10,10,10,@shopID);
select @reviewID from inserted;
update bill set ctobreview_id = @reviewID where id = @billId;
end
如果改成mysql应该怎么改啊 谢谢了啊
delimiter ||
create procedure test()
begin
DECLARE billId,reivewID,shopID,productID int ;
select id into billId from bill where status = 2 and ctobreview = null;
SELECT product_id into productID from billitem where bill_id = billId;
select shop_id into shopID from product;
insert into ctobReview values(2,null,null,10,10,10,10,shopID);
-- select @reviewID from inserted;
select last_insert_id();
update bill set ctobreview_id = reviewID where id = billId;
end||
delimiter ;