A SQL to insert continuous values
2024-08-21 23:48:28
I need a table to store all the working days. I dont like loop, so I tried sql. The following is the SQL I used.
insert into tb_working_days(data_date,day_type)
select DATE_ADD(data_date,INTERVAL (select count(1) from tb_working_days) day),"W"
from tb_working_days ;
At first, I insert one date into the table.
Then I run this sql once, I get two rows. Run once more, I get four rows, as so on.
after 10 runs, I get more than 1000 rows. the work is done.
The most interesting point is the sql after Interval, and it makes the magic. The db is smart enough to convert a set into a int. that is amazing.
最新文章
- 妈妈再也不用担心我找不到spring源码了!
- C# 版本的冒泡排序,包括该死的控制台读取
- 基于2d Tool Kit 精灵合图,动作生成工具
- Object-c 语言
- How to Notify Command to evaluate in mvvmlight
- 用C语言代码判别CPU的大小端模式
- Java WeakReference的理解与使用
- asp.net mvc4 Controller与Action执行过程的研究(学习笔记)
- vue写请求接口--请求参数的变量要在return里面声明
- linux中/etc/profile、/etc/profile.d/、/etc/bashrc、~/.bashrc、~/.bash_profile、~/.bash_logout的作用与区别
- SSL证书安装(Tomcat)腾讯云服务器
- 解析/proc/net/dev
- Codeforces Round #324 (Div. 2) E
- pachi 学习
- <;基础>; PHP 数组操作
- 10.Mysql索引
- Mybatis笔记三:MyBatis的API文档
- 【leetcode】804
- ftp之心脏病
- tyvj P3737 逐个击破
热门文章
- 14.7.1&;14.7.2
- 51. N-Queens (Array; Back-Track, Bit)
- UVa 12100 Printer Queue(queue或者vector模拟队列)
- linux-radhat-gitlab服务搭建
- 面向对象 Java练习
- [PHP] constant variable
- UI设计必用工具 — AI快捷键大全
- 连接数据库-corina
- 8个设计师必看的免费UI图标设计资源站
- javax.mail 发送邮件 , greenMail 测试 , spring