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
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
从NoSQL到NewSQL——10年代大数据浪潮下的技术革新
原創
2024-04-28 23:12:26
MySQL查出时间比实际晚8小时的解决方案
原創
2024-04-27 01:09:40
clickhouse vs starRocks|||
原創
2024-04-26 11:25:43
从零开始学架构V2-架构设计流程-2
原創
2024-04-25 23:56:26
从零开始学架构V2-初识架构设计-1
原創
2024-04-25 23:56:25
MySQL 核心模块揭秘 | 15 期 | 事务模块小结
原創
2024-04-24 23:20:56
一则 TCP 缓存超负荷导致的 MySQL 连接中断的案例分析
原創
2024-04-24 23:20:53
DataGear 5.0.0 发布,数据可视化分析平台
原創
2024-04-24 21:42:05
DataGear 企业版 1.1.0 发布,数据可视化分析平台
原創
2024-04-24 21:42:05
MySQL死锁排查,原来我一直没懂。。。
原創
2024-04-23 23:10:58
告别手动调度,海豚调度器 3.1.x 集群部署让你轻松管理多机!
原創
2024-04-23 21:18:20
MyDumper “喜欢” 触发器么?
原創
2024-04-22 23:19:50
windows 安装 mysql8.0 服务免安装版
原創
2024-04-20 11:23:47
6个实例带你解读TinyVue 组件库跨框架技术
原創
2024-04-26 10:33:20