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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.