Common MySQL Queries

Table of Contents

I ran across this terrific resource, Common MySQL Queries.

Tons of great examples…for example:

Given a birthdate in @dob, here are two simple formulae for age in years:

Date_format( From_Days( To_Days(Curdate()) - To_Days(@dob) ), '%Y' ) + 0
Year(Curdate()) - Year(@dob) - ( Right(Curdate(),5) < Right(@dob,5) )

and here is one for age in years to two decimal places, ignoring day of month:

Round((((Year(now()) - Year(@dob)))*12 + (((Month(now()) - Month(@dob)))))/12, 2)

Enjoy!

Tags :

Related Posts

WOTD: Gonfalon

A Gonfalon is a type of flag or banner suspended from a crossbar.

Read More
"The Body Myth: Adult Women and the Pressure to be Perfect" by Margo Maine, Joe Kelly

"The Body Myth: Adult Women and the Pressure to be Perfect" by Margo Maine, Joe Kelly

alter-text

Reviewer: Linda

While this is not the most well-written book I have read, it is thought provoking. Aimed generally at eating disorders that cause women to starve themselves (anorexia or bingeing and purging) it has some applicability to anyone with an eating disorder. The book concentrates mostly on the media and the “body myth” from there, i.e., all women should look like teenager boys but with big boobs.

Read More
Basket Weave Beanie

Basket Weave Beanie

I just added my first pattern to Ravelry. The pattern is for a great little beanie using the Basket Weave pattern.

Enjoy!

Read More