Some quick ways to remember your SQL; here are some "flashbulb moments" for newcomers and occasional users of MySQL and other SQL databases.
A database daemon is a process that looks after a number of DATABASES each of which comprises a number of TABLES each of which comprises data arranges in ROWS and COLUMNS.
You don't access database information directly on the disc from any application program - you access it via your database daemon (a program called mysqld) which is usually running all the time and MUST be running whenever you want to access your data.
You SHOW to look at the structure but you SELECT to look at the content.
You UPDATE the content of table rows but you You ALTER the structure of a table.
You choose rows from a result set with a WHERE clause but you choose rows after you've grouped them with a HAVING clause.
You add tables to each other "side by side" with a JOIN and you add results sets above/below each other with a UNION.
You use a USE command (or other function call) to set the current DATABASE but there is no concept of current TABLE to carry through from one query to the next on a connection.
REPLACE gets rid of existing rows and puts new data in their place, but UPDATE changes existing rows in situe and leaves columns that you don't re-specify unaltered. DELETE gets rid of rows completely, and INSERT puts in completely new rows.
Every row in a table has the same structure (homogeneous) but different columns will have different structures (hetrogeneous).
If you JOIN tables, you tell MySQL how the tables are to be connected to each other (which row(s) in the first table match which row(s) in the second) using an ON clause.
A regular JOIN return only result rows where the ON clause matches up a row from each table exactly, and a LEFT JOIN return the same results and IN ADDITION any records from the left hand table specified, NULL padded to make a complete result record.
You use = to check whether something has an exact value, but you use IS NULL to check for the total absence of any defined value.
Some useful resources ...
See our MySQL FAQ
for further useful articles and the main MySQL web site for the full MySQL reference manual
We teach private MySQL courses at our centre
and we run public courses
too. If you've a group of trainees who all need the same course at the same time, we can run a course at your office
We run a user forum
where you can ask questions to which you can't easily find the answer elsewhere, and we post up longer articles
in our solution centre. Further information is grouped by topic such as SQL Primer
, more complex SQL commands
, MySQL installation and admin
, how to design a database
and writing applications to use a database
. (written 2006-02-04, updated 2006-06-09)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesS157 - More MySQL commands 
MySQL - LEFT JOIN and RIGHT JOIN, INNER JOIN and OUTER JOIN - (2004-12-20) 
MySQL - Optimising Selects - (2004-12-21) 
Getting a list of unique values from a MySQL column - (2005-04-14) 
Matching in MySQL - (2005-09-24) 
MySQL - a score of things to remember - (2005-11-12) 
SELECT in MySQL - choosing the rows you want - (2005-11-22) 
MySQL - JOIN or WHERE to link tables correctly? - (2005-12-01) 
MySQL - an FAQ - (2005-12-03) 
An occasional chance, and reducing data to manageable levels - (2005-12-04) 
Combining similar rows from a MySQL database select - (2006-01-17) 
Giving the researcher power over database analysis - (2006-01-22) 
Saving a MySQL query results to your local disc for Excel - (2006-01-29) 
Helicopter views and tartans - (2006-04-06) 
MySQL - the order of clauses and the order of actions - (2007-06-01) 
Outputting numbers as words - MySQL with Perl or PHP - (2007-06-17) 
MySQL joins revisited - (2007-09-03) 
Joining MySQL tables revisited - finding nonmatching records, etc - (2008-03-15) 
Finding words and work boundaries (MySQL, Perl, PHP) - (2008-08-03) 
Ruby, Perl, Linux, MySQL - some training notes - (2008-11-23) 
MySQL - looking for records in one table that do NOT correspond to records in another table - (2009-03-31) 
Grouping rows for a summary report - MySQL and PHP - (2009-06-27) 
MySQL - efficiency and other topics - (2009-10-10) 
Relating tables with joins in MySQL - (2010-02-21) 
Counting rows in joined MySQL tables - (2010-02-22) 
Optimising and caching your MySQL enquiries - (2010-02-22) 
Removing duplicates from a MySQL table - (2010-02-22) 
Databases - why data is split into separate tables, and how to join them - (2010-11-20) 
SQL - Data v Metadata, and the various stages of data selection - (2011-04-29) 
Extracting data from backups to restore selected rows from MySQL tables - (2015-05-01)S153 - Sourcing, Running and Configuring MySQL 
Current MySQL and PHP paths and upgrades - (2005-01-28) 
Symbolic links and hard links - (2005-06-02) 
Which MySQL server am I using? - (2005-11-07) 
MySQL permissions and privileges - (2005-12-20) 
Browser -> httpd -> Tomcat -> MySQL. Restarting. - (2006-10-28) 
Apache httpd , browser, MySQL and MySQL client downloads - (2007-02-28) 
mysqldump and mysqlrestore - (2007-03-30) 
MySQL - Password security (authentication protocol) - (2007-04-02) 
Some sideways thoughts on the news - (2008-06-27) 
Apache httpd, MySQL, PHP - installation procedure - (2008-08-01) 
More HowTo diagrams - MySQL, Tomcat and Java - (2008-08-24) 
Summary of MySQL installation on a Linux system - (2008-12-11) 
MySQL - licensing issues, even with using the name - (2009-03-16) 
Monitoring and Tuning your MySQL installation - (2009-05-31) 
Which version of MySQL am I running? - (2009-09-26) 
Potted MySQL installation - (2009-10-09) 
Securing MySQL on a production server - (2009-10-09) 
Cant connect to local MySQL server through socket /tmp/mysql.sock - (2009-10-17) 
Checking MySQL database backups have worked (not failed) - (2015-01-10) 
Fixing damaged MySQL tables - Error 1712 and Error 2013 - (2015-01-25) 
Starting MySQL. ERROR! The server quit without updating PID file - how we fixed it. - (2015-05-06)S152 - SQL Primer as Used in MySQL 
NULL in MySQL - (2005-04-06) 
How do I query a database (MySQL)? - (2009-06-15) 
INSERT, DELETE, REPLACE and UPDATE - changing the content of SQL tables - (2010-11-19) 
Which database should I use? MySQL v SQLite - (2013-02-16)S151 - Introduction to SQL and MySQL 
MySQL - nuggets - (2004-10-11) 
Present and future MySQL - (2004-10-12) 
Worthwhile - (2005-01-11) 
Central London Courses - Perl, PHP, Python, Tcl, MySQL - (2005-07-18) 
Database or Progamming - which to learn first? - (2005-09-13) 
Testing you Perl / PHP / MySQL / Tcl knowledge - (2006-04-19) 
Databases needn't be frightening, hard or expensive - (2006-11-08) 
The LAMP Cookbook - Linux, Apache, MySQL, PHP / Perl - (2006-11-13) 
Oracle take over Sun who had taken over MySQL - (2009-04-21) 
The future of MySQL - (2010-01-03) 
Extra MySQL course dates (2 day course, UK) - (2010-01-08) 
Factory methods and SqLite in use in a Python teaching example - (2010-05-29) 
Files or Databases? MySQL, SQLite, or Oracle? - (2011-04-28) 
Storing your intermediate data - what format should you you choose? - (2012-11-20)
Some other Articles
Add a friendly front end with TkTwice is a co-incidence and three times is a patternFinding where the disc space has goneNOT Gone phishingKey facts - SQL and MySQLDanny and Donna are getting marriedRobust PHP user inputsChanging @INC - where Perl loads its modulesJob vacancy - double agent wantedPerl Regular Expressions - finding the position and length of the match