Skip Navigation

MySQL Cheat Sheet

The MySQL cheat sheet is designed to act as a reminder and reference sheet, listing useful information about MySQL. It includes a list of the available functions in MySQL, as well as data types. It also includes a list of MySQL functions available in PHP, and a list of useful sample queries to select data from a database. A description of what is on the cheat sheet follows, or if you are impatient, you can go straight to the full size MySQL cheat sheet:

Functions in MySQL

Thumbnail highlighting mysql functions. Many developers are completely unaware that MySQL actually has a huge number of functions built in, to do everything from regular expression-based string comparisons to complicated mathematical calculations. The outsides of the cheat sheet list MySQL functions (note: a few of the more unusual and least used functions have not been included due to constraints of space).

MySQL Data Types

Thumbnail highlighting data types section. MySQL allows for many data types for columns, and it is very easy to forget what constraints there are on these data types. This is especially important when it comes to validation - many developers do not check the length of data before inserting it into a table. This section lists the data types available and their constraints.

MySQL Functions in PHP

Thumbnail highlighting mysql function in PHP. PHP has a MySQL module and this is used by most PHP developers to connect to, and query, a MySQL database. This section lists the functions available in PHP for connecting to and managing a MySQL database.

Sample Queries

Thumbnail highlighting sample queries list. Finally, the cheat sheet includes a short list of sample queries and a brief explanation of each.

Download

So now that you know what it does, please feel free to print out the MySQL cheat sheet:

Please note: If you wish to link to the MySQL cheat sheet from elsewhere, please link to this page so others find the description, rather than linking directly to the sheet.

And finally, if you like the cheat sheets, and want to say thanks, please consider buying me something from my Amazon Wishlist. Thankyou very much to those who have already hunted it down and sent me something nice - I'm very grateful!

99 comments

 Saudi Arabia #1: May 24, 2005
Great job as usual !!
 United States #2: May 24, 2005
NICE, I was directed here by a friend of mine...grreat stuff, thank you so much...the cheatsheets will come inhandy since Im learning to do web stuff. My page is coded sloppy, but I'm learning
Thanks for another great help hanging at the wall beside my desktop...
Well done. It's good to see that some one is making excellent cheat sheets for reference :)
I strongly recommend not to use those MySQL-internal functions that are not in the SQL-standard, as this will tie you to this specific database and you can't switch to a real database (PostgreSQL, Oracle) once you have grown up.
 United Kingdom #6: May 26, 2005
These are all really handy - I don't need the css one but I've only recently started doing mysql stuff so this will prove very useful indeed.

Thanks for making them.
 Netherlands #7: May 26, 2005
People like 'mysql sucks' always crack me up: "I have never used Mysql and i never will, because it SUCKS!".

Perhaps Mysql isn't the best choice for every problem, but the one who needs to do some growing up is you.

Anyhow, thanks for the cheatsheet. And for providing it as a pdf.
cb
United States #8: May 26, 2005
Many thanks for posting these sheets (php,css,+mysql). I use them a great deal. I hope I can return the favor sometime
I would be great to have a PostgreSQL cheat-sheet as well. Could you please prepare one at convenient for you time and post it on www.postgresql.org site? I think it will benefit you a lot in terms of popularity.
BQ
United Kingdom #10: June 2, 2005
Very nice cheatsheet. It will come in well handy for me as I'm just getting to grips with this whole dynamic web stuff! Thanks again.
The Mysql pdf cheat sheet does not show up as crisp as the other cheat sheets. An image perhaps?
There is a problem with the MySQL PDF but I haven't been able to work out what it is yet. I'll have a new version up as soon as I've found a solution though.
hzane
United States #13: June 12, 2005
thanks man and nice work.
Konstantin
Finland #14: June 14, 2005
Keep them coming. Great job!
Joen
Norway #15: June 19, 2005
Excellent work on all of these cheat sheets. I'd like to add a suggestion: UNIX File Permissions Cheat Sheet :)
 United Kingdom #16: June 22, 2005
Thanks for another excellent cheat sheet to hang beside the other three :D

Glancing at the MySQL sheet I just noticed a small typo: ' Return **maxium** value in column as "alias" '

My cheatsheet wishlist: Perl, PostgreSQL
 United Kingdom #17: June 30, 2005
Heh nice, another bookmarked page!
Ahmed
Germany #18: July 5, 2005
Please, make a cheat sheet for JavaScript too.

Thanks in advanced.
Great!
You have a link at:

http://www.businessweek.cz/mod_rewrite-mysql-php-css-tahaky-prehledy.html

I´m looking forward to next cheat sheets :)
Bye.
That's Good. Thanks men.

The Cheat Sheet group is wonderfull.
Great sheet. Thanks for your work. Could you add query examples (one or two would be enough) for insert, delete and update statements? I think this is the only thing still missing.
Very very useful. Also PHP Sheet is very useful.
Miguel
Venezuela #23: September 8, 2005
This cheat sheet is great shit, Thanks man!!!
Peter, I have created a postgresql cheat sheet here: http://www.petefreitag.com/cheatsheets/postgresql/
Awesome, I haven't look at the cheat sheet yet, but I figure out that it will come in handy when I need it. Anyway, I know MySql for quite some times, and as a lead developer in my company, I made a big decision by choosing MySql as out main database backend for our commercial product. So this cheat sheet will be really usefull for the other programmer, due to their limited knowedge about the power of MySql. I believe this will help us in maximizing MySql during the development proccess.

Thanks again fof spending your precious time in building this cheat sheet. May you be blessed :)

Sincerely,
Wendy Novianto
helpful stuff, but as 'mysql sucks' said: eg postgresql is better than mysql. Using Pg and all of its capabilities may boost performance of the app.
 Russian Federation #27: November 9, 2005
This cheat sheet is really cool!
Thanks. It's great. I used to do my own cheatsheets for unix/linux/shell stuff and take them with me from place to place (written in excel), with examples so i remeber how to use the commands. This is much nicer. Thank you :-)
Indoxyl Designs
Canada #29: April 14, 2006
Great cheat-sheet!
Arup Garai
India #30: May 5, 2006
this is to much use full for beginer and as well as who is professional
 United Kingdom #31: May 8, 2006
You rock! Useful stuff to print out and put on my desk divider!!
great job.
Thanks
Brandon
United States #33: July 11, 2006
Dave..

Thanks so much for the cheat sheets! Learning php & MySQL is a pretty daunting task for the beginner. This is making it much easier!
Grace
United States #34: July 19, 2006
Thank you so much...this is a great tip sheet when creating queries.
Nomo Takanori
Japan #35: August 21, 2006
This is so magical. I like very much yes. It is very much good.
81403
Slovakia #36: August 31, 2006
excellent job with all the cheat sheets!
well, except for one thing - why are some of them in some kind of bitmap format even though they are pdf-s?
Thanks for this site. Its very in"site"full. Sorry for the pun. I found the cheat sheets very useful in addition to the information you have provided. Thanks for the information.
Kamran
Pakistan #38: October 27, 2006
Always nice to have free and quality material :) thanks a lot for that!
Hi,

currently I am learning programming.
I found techcheatsheets.com and browsed the site.
This happenend from time to time.
I bought some books and read them.
I worked through tutorials.

These one page- quick guides of you are the best thing ever!
Thanks so much for making this public and for free!

Regards Jochen
James
United Kingdom #40: November 11, 2006
I htink the syntax for INSERTS and UPDATES and DDL would have been more useful that SELECT samples.
Andy Wright
United Kingdom #41: November 17, 2006
RE: Comment 12 (above).
I think you have a transparency issue (perhaps a big transparent box above the text?). The text of this cheat sheet has been flattened (converted to outlines) and transparency is the usual cause of this.

Delete ANYTHING that isn't 100% opaque and try distilling again...

HTH

PS. These cheat sheets are AWESOME--thank you very much! :)
yasar -- uk
United Kingdom #42: December 12, 2006
cool cool cool dnt knw anything yet but ill use it in future
Came here via digg. Good stuff, cheers :)
Phatphreak
Unknown #44: December 14, 2006
Very informative
Too bad it's not what I hoped for. It's the less used queries you forget the syntax of (insert, delete, etc) and this info is not on your sheet. Guess a difference in priorities, good job anyways!
Dubya
United States #46: December 14, 2006
Nice collection of cheat sheets. I've bookmarked it and will be back when I need assistance.
Anonymous
United States #47: December 14, 2006
what about "show variables like '%max%'"
That is nice, thanks, very useful
learn something new everyday!
Did it again ILJD!


Is there a generilized SQL cheatsheet for joins and other more complex statements?
Chris
New Zealand #51: December 19, 2006
Would have been nice to have UPDATE and INSERT examples included :)
Absolutely the best guide. I just learned commands i wasn't even aware of.
Great Cheatsheet. I'd like it even more if it had 1 delete, 1 insert possibly at the expense of a couple of those selects. But I'm downloading it and using it anyway. ;-)
Thanks for the cheatsheet! I encourage you to make updates as well. Or for MySQL in particular, maybe a separate sheet about Stored Programs and Views.

-Matt
 United States #56: August 28, 2007
I love your cheat sheets, they are terrific. Is it possible to put some sample insert, delete, and update queries in the list? Love it none-the-less !!!
These sheets are a big help for those of us juggling a lot of stuff. Thanks for putting them together!
Muhammad Khawar
Australia #58: September 21, 2007
Nice work! Thanks.
I love mysql chat, Good Work..
Wow, another great cheat sheet. Thankyou!
I like this cheat sheets, they are good.
Great jobs !

Thanks.
rhen
Australia #62: October 6, 2007
so good even if it is a new program for me
stabby
Unknown #63: October 8, 2007
you rock!
arthur white
United States #64: October 29, 2007
to Msql sucks to each his own maybe it is not the best but it is a place to start and maybe it fits the app which it is being used for but no reason to completely run it into the ground. Just because you cannt use it doesnt mean some of us other can not.

newbie Arthur White
All on one page, this is fantastic!!!

10x!
Thank's for the cheat sheet. I've already click your adsense many times for payment.

Suggestion for next cheat sheet:
make it more complete by giving shorts description below the context, we still accept if page amount between 10 to 30 pages.
Great stuff...
it saves lot of digging work..
Good work..
Thanks a lot..
great work, and i translated into chinese:

PDF format: http://www.gracecode.com/upload/2007_11_28/1196228303.pdf
ZIP format(includes PNG and PDF):http://www.gracecode.com/upload/2007_11_28/1196228319.zip
PNG format: http://photo14.yupoo.com/20071127/131755_496400892_mylnymzf.jpg
My blog:http://www.gracecode.com/Archive/Display/257
Thanks! just starting to learn MySQL and PHP, this should be very helpful!
Really! really!!!! nice work dude!

I was looking for a MySQL reference, but nothing so perfect like that! Thank you man! I love you!

(sorry for my bad english) ;)

I've bookmark your site, I will add a link on my site, you deserve it!!
PSREDDY
Australia #71: December 13, 2007
Simply excellent work. Requesting to add online bookmark like del.icio.us etc.,
Very useful.
Thanks a lot, great job.
Greetings.
Thanksssssssssssssss
London jobs
United Kingdom #74: January 1, 2008
Hi, Great Cheatsheet. I'd like it even more if it had 1 delete, 1 insert possibly at the expense of a couple of those selects. But I'm downloading it and using it anyway.
Hello, to Msql sucks to each his own maybe it is not the best but it is a place to start and maybe it fits the app which it is being used for but no reason to completely run it into the ground. Just because you cannt use it doesnt mean some of us other can not.
Any chance for another version that has mysqli_ functions?
Hello, my name is Praca.
Great sheet. Thanks for your work. Could you add query examples (one or two would be enough) for insert, delete and update statements? I think this is the only thing still missing.
Great sheet. Thanks for your work.
Thank you! Very nice and interesting article.
baliwebdesigner
Australia #80: February 18, 2008
i download almost all of files in cheat sheet section :) awsome list
Mehmet
Germany #81: February 24, 2008
Good Work..would be nice to add triggers and functions since they are now available in version 5.x

Greetings
Cool. It help me a lot. This is also may be use ful...

http://www.nparikh.org/unix/mysql.php
Joe
United States #83: February 29, 2008
Cool! I love these cheat sheets. Been wanting to do them for myself forever. Now there's no need.

Thanks!
everybody now i think
Nice website and another great article :)
Thank you for the good articles have helped me a lot.
 United Kingdom #87: March 20, 2008
Great work! Will save a lot of time searching on the MySQL website...
Anonymous
United States #88: March 24, 2008
wtf!! just looking for info related to jack daniels...with cross references....forget about it!!!!!!!!!!!!!!!!!!!....lol
Tim
Unknown #89: March 28, 2008
Quick way to make a pdf... drop the png image into OpenOffice writer and export as pdf. Works great.

Thanks for the cheat sheets.
Lakul
India #90: May 13, 2008
hi,
the problem what i m facing is, My "Mysql" connection doesnt gets live for a long time it drops connectivity if we open connection but not firing any type of query for long time.

"How can make mysql connection live for 24 hours ?"
Ajay Patel
India #91: May 23, 2008
Great Job
THanks Ahead for Giving Too much Support in Mysql.
Alex
Ukraine #92: June 8, 2008
Thank you!!!
Niraj
United States #93: June 26, 2008
This is really cool.. Great stuff man.... Thanks!!
One of the most useful things I've ever stumbled across!

Thank you, I appreciate the effort!
Thanks! I have used your cheat because I understand that is so interesting for all PHP programers. I am a programming teacher and I see this cheat so interesting for my pupils and I've published at our forum.
yaaachao
China #96: November 13, 2008
it is great.
XTend
Romania #97: November 20, 2008
Thanks a lot for this posterlike view of MySQL basics.
As db engine I use MSSQL, Oracle and MySQL of course.
Why ?
Because I can.

Yes MySQL is a little behind, but the new versions stand-up and I consider MySQL a high quality product within Open Source products.
Hi, There I have a problem with the MySQL PDF. I haven't been able to work out what it is yet. I'll have a new version up as soon as I've found a solution though. Could help for me.
Christopher
Karasov
Ternovka UA #99: December 30, 2008
Thanks, Great jobs!!!

Post Your Comment

· Comments with keywords instead of a name have their URLs removed.
· Your email address will not be displayed or shared.

Live Comment Preview

 United States #100: 1 minute ago