For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > June 2005 > Filling in missing dates









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Filling in missing dates
laredotornado@zipmail.com

2005-05-31, 4:00 pm

Hello, I'm using PHP 4 and MySQL 4. I have a table that has two
columns -- DAY and SALES. Let's say the values are as such:

DAY SALES
--- -----
5-29-05 15
5-31-05 5

Is there a way in MySQL to select 3 rows of data from the table where
the 3rd row would be

5-30-05 0

? I am hoping to construct a single query to do this. Any help you
hvave is greatly appreciated, - Dave

Martin Steiger

2005-06-02, 9:02 am

It would be possible with one query if you'd add an additional table with
all dates (e.g. until 2010 or so). There is an example by "santi bari" on
http://dev.mysql.com/doc/mysql/en/d...functions.html.

Other possibility would be to create an array with the required interval
first and then fill it with the required values from mysql.

Martin


<laredotornado@zipmail.com> schrieb im Newsbeitrag
news:1117545071.031614.165360@g14g2000cwa.googlegroups.com...
> Hello, I'm using PHP 4 and MySQL 4. I have a table that has two
> columns -- DAY and SALES. Let's say the values are as such:
>
> DAY SALES
> --- -----
> 5-29-05 15
> 5-31-05 5
>
> Is there a way in MySQL to select 3 rows of data from the table where
> the 3rd row would be
>
> 5-30-05 0
>
> ? I am hoping to construct a single query to do this. Any help you
> hvave is greatly appreciated, - Dave
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com