homepage Welcome to WebmasterWorld Guest from 50.16.169.220
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
inserting calendar rows with other inserts
helenp




msg:4397956
 8:16 pm on Dec 14, 2011 (gmt 0)

Hi,
On this link they explain how to insert date rows to a table, and it looks like it works perfect, the only thing it inserts until year 2042 and I dont want that many, suppose that can be changed in the script.

But at the moment what I am trying to do is at the same time when I insert the daterows I want to insert other information belonging to those dates.
This is the link:
[brianshowalter.com...]

First I created the table with the columns: property, price, description and dt.

Then I created another table to calculate the dates:
CREATE TABLE ints ( i tinyint );
INSERT INTO ints VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

And then I am supposed to do this:
INSERT INTO calendar_table (dt)
SELECT date('2010-01-01') + interval a.i*10000 + b.i*1000 + c.i*100 + d.i*10 + e.i day
FROM ints a JOIN ints b JOIN ints c JOIN ints d JOIN ints e
WHERE (a.i*10000 + b.i*1000 + c.i*100 + d.i*10 + e.i) <= 11322
ORDER BY 1;


However as I said I want to add: property, price and description and the dates at the same time.
Been trying several ways in phpmyadmin but get the error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2010-01-01') + interval a.i*10000 + b.i*1000 + c.i*100 + d.i*10 + e.i day FROM i' at line 2
trying to do this:

INSERT INTO calendar_table (property, price, description, dt)
values ('Casa_Blanca_4', '85', 'easter', 'SELECT date('2010-01-01') + interval a.i*10000 + b.i*1000 + c.i*100 + d.i*10 + e.i day
FROM ints a JOIN ints b JOIN ints c JOIN ints d JOIN ints e
WHERE (a.i*10000 + b.i*1000 + c.i*100 + d.i*10 + e.i) <= 11322)'
ORDER BY 1;


Is it posible to do what I am trying to do?
and I suppose changing the numbers 10000 etc I will get less dates.
Thanks,
Helen

 

helenp




msg:4397976
 9:01 pm on Dec 14, 2011 (gmt 0)

And thinking, the best would be instead of adding dates from given date x years, the best would be to add until a given year....maybe that is to much :)

helenp




msg:4398167
 10:23 am on Dec 15, 2011 (gmt 0)

Puf, it does not seem it will work, as it dont seem to be posible even to add only the dates more than once...I wanted to do with mysql instead of php, so if anybody know how to insert dates if posible to a given date in mysql using only mysql, appreciated.
Thanks

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved