Posts Tagged union

Generate Date from a range in Mysql and pad the results where no date is present

If you want to generate dates, MYSQL doesn’t have a range function, so I wrote a work around for the same. So how  it works is I have reused a code to generate numbers from my previous post. So I added date function to that query and reduce the generated numbers from the date. Hence effectively its Currrent Date – x number of days. Thus we generate the dates from the date we provide to the x number we generate. So here is the code:

Continue reading “Generate Date from a range in Mysql and pad the results where no date is present” »


, , , , , , , ,

No Comments

Generate 1 to 1000 in mysql

Sometimes its necessary to have thousand rows to join or generate new values, we need to get the thousand rows first. For this I used union of numbers 0-9.  I have joined four of these to get to four digit values. So here is the code:

Continue reading “Generate 1 to 1000 in mysql” »


, , , , , , , ,

2 Comments