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.

A SQL to insert continuous values的更多相关文章

  1. sql动态insert向varchar(MAX)中写入据的问题

    sql动态insert向varchar(MAX)中写入据的问题,在写入时出现列无效.后来发现,varchar要加''两个,号才可以 SET @SQL='INSERT INTO '+@TabName+' ...

  2. SQL Server Insert操作中的锁

    原文:SQL Server Insert操作中的锁 这篇博文简单介绍一下在SQL Server中一条Insert语句中用到的锁. 准备数据 首先我们建立一张表Table_1,它有两列Id(bigint ...

  3. ORA-00913错误:PL/SQL: ORA-00913: too many values

    ORA-00913错误 描写叙述:PL/SQL: ORA-00913: too many values 目标:编写一个能够循环插入数据的脚本 操作过程: SQL> desc tcustmer N ...

  4. Delphi X10.2 + FireDAC 使用 SQL 语句 INSERT

    // CREATE TABLE [tabusers]( // [id] INTEGER PRIMARY KEY AUTOINCREMENT, // [username] CHAR NOT NULL, ...

  5. Mybatis执行sql(insert、update、delete)返回值问题

    数据库:Mysql 在使用mybatis的过程中对执行sql的返回值产生疑问,顺手记录一下. 结论: insert:   插入n条记录,返回影响行数n.(n>=1,n为0时实际为插入失败) up ...

  6. sql学习--insert

    insert的四种插入方式 第一种最简单的 into 和目标列的列表是可选的 intsert [into] tableA [(col1,col2)] values(val1,val2) 第二种 ins ...

  7. sql在insert时判断有无唯一性冲突

    sql在insert时判断有无唯一性冲突,存在相同主键或唯一索引,则不创建 INSERT INTO table(field1, field2, fieldn) SELECT 'field1', 'fi ...

  8. sql server insert values 多值 与oracle 的不同

    类似的语句在 oracle 中是不能执行的 insert into temp_tbl values('app'),('demo'); 但是在sql server 中是可以的 insert into c ...

  9. FMDB存储模型对象(以二进制存储)用NSKeyedArchiver archivedDataWithRootObject序列号,NSKeyedUnarchiver unarchiveObjectWithData反序列化(重点坑是sql语句@"insert into t_newsWithChannel (nwesName,newsType) values (?,?)")一定要用占位符

    交友:微信号 dwjluck2013 一.封装FMDB单例 (1)JLFMDBHelp.h文件 #import <Foundation/Foundation.h> #import < ...

随机推荐

  1. wireshark使用相关问题

    问题1: 打开wireshark,没有出现过滤器 解决1: 使用管理员方式登录 过滤: http and ip.src == 192.168.0.10 and ip.dst == 192.168.0. ...

  2. hdoj1260 Tickets (简单DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260 思路: 很简单的DP题,状态方程也比较容易想到,用f[i]表示到第i个人所耗的最短时间,详见代码 ...

  3. The Doors(几何+最短路,好题)

    The Doors http://poj.org/problem?id=1556 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions ...

  4. Aactivity和Service之间的通信

    一.在activity中定义三个按钮 一个开启服务  一个关闭服务,还有一个是向服务发送广播 当创建出Serevice时先执行Service的onCreate()创建服务后只执行一次 以后每次点击开启 ...

  5. struts2框架值栈的概述之问题一:什么是值栈?

    1. 问题一:什么是值栈? * 值栈就相当于Struts2框架的数据的中转站,向值栈存入一些数据.从值栈中获取到数据. * ValueStack 是 struts2 提供一个接口,实现类 OgnlVa ...

  6. JTemplate学习(一)

    使用模板绑定数据,可以嵌套循环 参考:http://www.doc88.com/p-6621237324128.html <!DOCTYPE html PUBLIC "-//W3C// ...

  7. 『SpringMVC』<context:include-filter>&<context:exclude-filter>爬坑

    原文地址:https://segmentfault.com/a/1190000012972619 大家好,我是猪弟,猪在我心中从来不是蠢的代名词,而是懒的代名词,本次准备记录一个在开发测试过程中遇到的 ...

  8. Java8 改进的匿名内部类:

    1.匿名内部类适合创建那种只需要一次使用的类 2.匿名内部类定义格式: new 实现接口() | 父类构造器(实参列表){ //匿名内部类类体部分 } 3.从上面定义格式可以看出,匿名内部类必须实现一 ...

  9. geoserver 的缓存技术

    geoserver提到的缓存工具共有两个:tilecache和geowebcache.geowebcache是java写的,整合进geoserer中. tilecache则是python写的一个小程序 ...

  10. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...