MySQL Basics: Select Exercises

From XPUB & Lens-Based wiki
Revision as of 00:44, 23 May 2008 by Michael Murtaugh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The US Government organizes and publishes online a publically accessible database of various information and statistics organized by country. Each year, a new version of the "CIA Worldfactbook" is made available. Via the website ( it's possible to download the lot as a big zip of HTML files. Handy for planning your next coup when out of range of an Internet connection, but much more interesting would be to do retrieval / summarizing with SQL...

Happily, using the open source wfb2sql script,, it's possible to convert / scrape these HTML files into SQL suitable for "sourcing" into your very own MySQL database.

A sample resulting database (based on 2004 data):

  • attachment:factbook2004.sql.gz

Download the MySQL handouts! (8 pages) [1]


  • attachment:SQLSelectExercises1.pdf
  • attachment:SQLSelectExercises2.pdf