Jump to content

Createing a bookings system


jonniejoejonson

Recommended Posts

Hi

 

Firstly, set up a table with 1 column 10 rows, with values from 0 to 9. In this case call it integers and the column name of i.

 

Then if you do the following you can select a range of numbers (joining the table against itself repeatedly). This gives you every number from 0 to 999, and the HAVING clause reduces it to 0 to 365.

 

SELECT a.i *100 + b.i *10 + c.i AS SomeNumber
FROM integers a, integers b, integers c
HAVING SomeNumber <=365

 

You can then add that number of days to a start date to get a range of dates. For example:-

 

SELECT DATE_SUB( '2011-01-01', INTERVAL a.SomeNumber DAY )
FROM (SELECT a.i *100 + b.i *10 + c.i AS SomeNumber
FROM integers a, integers b, integers c
HAVING SomeNumber <=365)a

 

All the best

 

Keith

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.