mysql更新前判斷

CREATE PROCEDURE video()
BEGIN
declare num int;
select count(id) into num from fa_video where user_id=5 and type=1 and status=2;
if(num=0)
Then
update fa_video set is_free=1 where user_id=5 and type=1 and status=1 ORDER BY createtime asc limit 1;
else
update fa_video set is_free=1 where user_id=5 and type=1 and status=2 ORDER BY createtime asc limit 1;
end if;
END
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章