在mysql中如何使用increment i=1, i++?
In mysql how to use increment i=1, i++?
<table border='1' cellspacing='0' cellpading='0'>
<tr>
<th>Month</th>
<th>Date</th>
</tr>
<tr>
<th>1st month</th>
<th>2/12/2014</th>
</tr>
<tr>
<th>2nd month</th>
<th>2/1/2015</th>
</tr>
<tr>
<th>3rd month</th>
<th>2/2/2015</th>
</tr>
<tr>
<th>4th month</th>
<th>2/3/2015</th>
</tr>
<tr>
<th>5th month</th>
<th>2/4/2015</th>
</tr>
<tr>
<th>6th month</th>
<th>2/5/2015</th>
</tr>
<table>
我有以下查询的用户仅在下个月添加我期望如何在 mysql 中增加一个值?
插入 tbl_book
(book_date
) 值(现在( )+ 间隔 1 个月)
我希望单个查询低于 table
使用mysql的dateadd函数。
DATE_ADD(date,INTERVAL expr type)
您希望间隔为 "MONTH"
INSERT INTO tbl_book(book_date) VALUES (date_add(now( ), INTERVAL 1 Month);
您可以在 http://www.techonthenet.com/mysql/functions/date_add.php
找到更多详细信息
计划 A:编写一个带有循环和计数器的存储过程。
计划 B:创建一个 table 整数,从 table 开始 SELECT,停在 6,并在日期算法中使用整数:
INSERT INTO tbl_book (book_date)
SELECT CURDATE() + INTERVAL n MONTH
FROM integers
WHERE n BETWEEN 1 AND 6;
<table border='1' cellspacing='0' cellpading='0'>
<tr>
<th>Month</th>
<th>Date</th>
</tr>
<tr>
<th>1st month</th>
<th>2/12/2014</th>
</tr>
<tr>
<th>2nd month</th>
<th>2/1/2015</th>
</tr>
<tr>
<th>3rd month</th>
<th>2/2/2015</th>
</tr>
<tr>
<th>4th month</th>
<th>2/3/2015</th>
</tr>
<tr>
<th>5th month</th>
<th>2/4/2015</th>
</tr>
<tr>
<th>6th month</th>
<th>2/5/2015</th>
</tr>
<table>
我有以下查询的用户仅在下个月添加我期望如何在 mysql 中增加一个值?
插入 tbl_book
(book_date
) 值(现在( )+ 间隔 1 个月)
我希望单个查询低于 table
使用mysql的dateadd函数。
DATE_ADD(date,INTERVAL expr type)
您希望间隔为 "MONTH"
INSERT INTO tbl_book(book_date) VALUES (date_add(now( ), INTERVAL 1 Month);
您可以在 http://www.techonthenet.com/mysql/functions/date_add.php
找到更多详细信息计划 A:编写一个带有循环和计数器的存储过程。
计划 B:创建一个 table 整数,从 table 开始 SELECT,停在 6,并在日期算法中使用整数:
INSERT INTO tbl_book (book_date)
SELECT CURDATE() + INTERVAL n MONTH
FROM integers
WHERE n BETWEEN 1 AND 6;