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

My Favorite Everything Socks

My Favorite Everything Socks

My first package from the wonderful Woolens & Nosh yarn club was from October, 2023, and since it was my first, I wanted to make something special with it. So I decided to knit a pair of socks using all of my favorite components.

The yarn base is great. It’s 90% superwash Targhee and 10% Nylon, and it is a delight to knit with. The colorway is described as Our Seasonal Offering: House made butternut squash ravioli with a brown butter and sage cream sauce.

Read More
The Galaxy Note II by Samsung

The Galaxy Note II by Samsung

I got an evaluation phone at work to fiddle with for 30 days. I’ve been a long time apple iPhone fan, and still am, but I’ve been hearing more and more good things about Android and Android phones that I figured it was time to check them out.

My first reaction when they handed me the box was, “Damn! This thing is huge!”

1Password yeah! I wasn’t smart enough to look for a 1Password android version first thing. It took me a couple of hours and several typed passwords before I wised up and searched. 1Password syncs with my dropbox password list just like on the iPhone.

Read More
German Clustered Cable

German Clustered Cable

Another Crazy Quilt swatch from Barbara Walker’s, A Treasury of Knitting Patterns Vol 1, page 274, the German Clustered Cable. Barbara describes the pattern as, “a simple German pattern consisting of knit-purl checks, with a single cable cross worked into each knit check.”

The finished result is delightful! It has texture and interest with wavy cables running over a sea of purl checks. My first thought was how fun this would be as a filler stitch on a sweater.

Read More