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. Java连接MySQL数据库及操作

    Java操作MySQL数据库,需要驱动mysql-connector-java 来进行操作,去下载对应的jar包   一.导入需要的jar包 我用的是maven对包进行管理,在maven中添加如下内容 ...

  2. django提交post请求

    在做post的时候,view.py用到了下面的方法,如果是POST的method,就通过request.POTST['XX']获得html中name为XX的值,然后将值save到数据库里 models ...

  3. org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]

    运行servlet程序报错: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Cat ...

  4. Graph Coloring I(染色)

    Graph Coloring I https://www.nowcoder.com/acm/contest/203/J 题目描述 修修在黑板上画了一些无向连通图,他发现他可以将这些图的结点用两种颜色染 ...

  5. Maven项目的拆分与聚合

    ---------------------siwuxie095                                     Maven 项目的拆分与聚合         1.对已有的 Ma ...

  6. UVa 12100 Printer Queue(queue或者vector模拟队列)

    The only printer in the computer science students' union is experiencing an extremely heavy workload ...

  7. SQL时间格式化 转载备用~

    Sel1 取值后格式化{0:d}小型:如2005-5-6{0:D}大型:如2005年5月6日{0:f}完整型 2 当前时间获取 DateTime.Now.ToShortDateString 3 取值中 ...

  8. c语言指针数组和结构体的指针

    指向数组的指针,先初始化一个数组,使用传统方式遍历 void main() { ] = { ,,,, }; ; i < ; i++) { printf("%d,%x\n", ...

  9. ViewPager欢迎界面

    一.几张图片组成欢迎界面 下方有几个点对应每个图片 当图片被选中时对应的点会变亮,当对应的点被点击时也会切换到指定画面 以下是代码 package com.example.viewpager_1; i ...

  10. linux下安装oracle数据库详细教程

    一.安装yum源 下载或拷贝RedHat的iso镜像到本地,比如 /repo/iso/ rhel-server-6.6-x86_64-dvd.iso 1.建立ISO文件存放目录(/repo/iso)和 ...