<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="0.xsl"?>
<!DOCTYPE html SYSTEM "zoo.dtd">
<html>
<head>
<meta name="keywords" content="SQL, tutorial, learn, database, relational database, structured query language, interactive, MySQL, SQL Server, Oracle, Access db2"/>
<meta name="author" content="Andrew Cumming"/>
<meta name="oblation" content="this will go. rejig will remove it"/>
<title>A Gentle Introduction to SQL</title>
</head>
<body>
<topbit tagline="Tutorials and reference."/>
<div style=''>Interactive SQL tutorial, learn about:
<code>SQL Server</code>, <code>Oracle</code>, <code>MySQL</code>, <code>DB2</code>, <code>Mimer</code>, <code>PostgreSQL</code>, <code>SQLite</code>
and <code>Access</code>.</div>
<div id='forstumblers' style='display:none'>
<qu id='Sample Query'>
<h2>Population of more than 200 million.</h2>
<p>Show the name and the population in descending order of population for each country that has a population of more than 200000000</p>
<def>
SELECT name, population
  FROM bbc
 WHERE population>200000000
ORDER BY population DESC
</def>
</qu>
<qu id='Sample Subquery'>
<h2>Twice the area of India.</h2>
<p>Show the name, region and area for each country with an area of two times the area of India.</p>
<def>
SELECT name, area
  FROM bbc
 WHERE area>=
  (SELECT 2*area FROM bbc WHERE name='India')
</def>
</qu>
</div>
<table style='clear:both'>
<tr>
<td width="50%">
<h3>Tutorial Section</h3>

<dl>
<dt><b>1) <a href="1.htm">SELECT:</a></b></dt>
<dd>In which we query the BBC country profile table.</dd>
<dt><b>2a) <a href="1b.htm">More practice with SELECT:</a>
          </b></dt>
<dd>Additional practice of the basic features using a table of Nobel Prize
    winners.</dd>
<dt><b>2b) <a href="1a.htm">SELECT in SELECT:</a>
          </b></dt>
<dd>In which we form queries using other queries.</dd>
<dt><b>3) <a href="2.htm">SUM and COUNT:</a></b></dt>
<dd>In which we apply aggregate functions.
 <span class='little'>[<a href='2b.htm'>more the same</a>]</span></dd>
<dt><b>4) <a href="3b.htm">The JOIN operation:</a></b></dt>
<dd>In which we join two tables; <code>ttms</code> and <code>country</code>.
    <span class='little'>[previously <a href="3a.htm">music tutorial</a>]</span></dd>
<dt><b>5) <a href="3.htm">More JOIN operations:</a></b></dt>
<dd>In which we join actors to movies in the Movie Database.</dd>
<dt><b>6) <a href="4a.htm">Using Null:</a></b></dt>
<dd>In which we look at teachers in departments.
<span class='little'>[previously <a href='4.htm'>Scottish Paliament</a>]</span></dd>
<dt><b>7) <a href="6.htm">Self join:</a></b></dt>
<dd>In which we join Edinburgh bus routes to Edinburgh bus
routes.</dd>
</dl>

<dl>
<dt><b>Please link to SQLZoo.net</b></dt>
<dd>SQLZoo is in danger falling off the first page for the search term "SQL"</dd>
<dt><b>SQL User Manuals</b></dt>
<dd class="teeny">[
 <a href="http://developer.mimer.com/documentation/html_92/Mimer_SQL_Engine_DocSet/Mimer_SQL_Engine.htm">
  Mimer</a> |
 <a href="http://dev.mysql.com/doc/refman/5.1/en/select.html">
  MySQL</a> | 
 <a href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#i2065646">
  Oracle</a>

 | 
 <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sa-ses_9sfo.asp">
  SQL Server</a>
 | 
 <a href="http://office.microsoft.com/en-us/assistance/CH062526881033.aspx">
Access</a>
 | <a href='http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/r0000879.htm'>DB2</a>
 | <a href="http://sybooks.sybase.com/onlinebooks/group-as/asg1251e/commands/@Generic__BookTextView/704;hf=0#X">Sybase</a>
 | <a href="http://www.postgresql.org/docs/8.2/interactive/index.html">Postgres</a>
 | <a href="http://www.sqlite.org/lang.html">SQLite</a>
]</dd>
<dd>Online copies of implementation specific user manuals.</dd>
<dt><b>Starting SQL</b></dt>
<dd class="teeny">[ <a href="commysql.htm"><code>MySQL</code></a>
    | <a href="comoracle.htm"><code>Oracle</code></a>
    | <a href="comsqlserver.htm"><code>SQL Server</code></a>
    | <a href="comdb2.htm"><code>DB2</code></a>
    | <a href="compost.htm"><code>Postgres</code></a>
    ]</dd>
<dd>How to connect to the server and execute SQL statements.</dd>

<dt><b>Programming with SQL</b></dt>
<dd class="teeny">[ <a href="web.htm">SQL in perl on the Web</a> |
<a href="java.htm">SQL from Java</a> ]</dd>
<dt><b>SQL standard</b></dt>
<dd class="teen">[ <a href="http://sqlzoo.net/sql92.html"><code>SQL92 BNF</code></a> ]</dd>
</dl>
</td>
<td>
<h3>Reference Section: how to...</h3>

<dl>
<dt><b>1)
<a href="howto/source/z.dir/i01select.xml">
 SELECT</a></b>:</dt>
<dd>How to read the data from a database.
</dd>
<dt><b>2)
<a href="howto/source/z.dir/i02create.xml">
 CREATE and DROP</a></b>:</dt>
<dd>How to create tables, indexes, views and other things. How to
get rid of them.</dd>
<dt><b>3)
<a href="howto/source/z.dir/i04insert.xml">
 INSERT and DELETE</a></b></dt>
<dd>How to put records into a table, change them and how to take
them out again.</dd>
<dt><b>4)
<a href="howto/source/z.dir/i06dates.xml">
 DATE and TIME</a></b></dt>
<dd>How to work with dates; adding, subtracting and
formatting.</dd>

<dt><b>5)
<a href="howto/source/z.dir/i08fun.xml">
 Functions</a></b></dt>
<dd>How to use string functions, logical functions and mathematical
functions.</dd>

<dt><b>6)
<a href="howto/source/z.dir/i10others.xml">
 Users</a></b></dt>
<dd>How to create users, GRANT and DENY access, get at other peoples
tables. How to find processes and kill them.</dd>

<dt><b>7)
<a href="howto/source/z.dir/i12meta.xml">
 Meta Data</a></b></dt>
<dd>How to find out what tables and columns exist. How to count and
limit the rows return.</dd>


<dt><b>Error Messages</b></dt>
<dd><a href='howto/source/z.dir/i30error.xml'>Some error messages
 from SQL engines</a></dd>
</dl>
</td>
</tr>

<tr>
<td>
<h3>Answers</h3>
<p>Answers to the tutorial questions.</p>
<ul>
<li><a href="1.htm?answer=1"><code>SELECT</code></a></li>
<li><a href="1a.htm?answer=1"><code>SELECT</code> in <code>SELECT</code></a></li>
<li><a href="2.htm?answer=1"><code>SUM</code> and <code>COUNT</code></a></li>
<li><a href="3b.htm?answer=1"><code>JOIN</code> I</a></li>
<li><a href="3.htm?answer=1"><code>JOIN</code> II</a></li>
<li><a href="4a.htm?answer=1"><code>OUTER JOIN (teachers)</code></a></li>
<li><a href="4.htm?answer=1"><code>OUTER JOIN (Parliament)</code></a></li>
<li><a href="5.htm?answer=1">ACME</a></li>
<li><a href="6.htm?answer=1">SELF JOIN</a></li>
<li><a href="7.htm?answer=1">Top of the Pops</a></li>
</ul>
<h3>Assessments</h3>
<p>These exercises involve larger databases.
Answers to these questions are not available to
students.
</p>
<ul>
<li><a href="a6.htm">AdventureWorks</a>: Flogging sports gear. Assessment for CO22008 2007/8</li>
<li><a href="a1.htm">Neeps</a>: A timetable database</li>

<li><a href="a2.htm">Musicians</a>: Concerts and
compositions</li>

<li><a href="a3.htm">Southwind</a>: Buying and selling</li> 
<li><a href="a4.htm">Dressmaker</a>: Constructing clothing</li>
<li><a href="a5.htm">Congestion Charging</a>: Monitoring traffic
 (<a href="b5.htm">old questions</a>)</li>
<li><a href="http://www.met-office.gov.uk/climate/uk/stationdata/southamptondata.txt">Weather data for Southhampton</a></li>
<li><a href="/big/album.txt">Album</a> <a href="/big/track.txt">Tracks</a>
<a href="/big/style.txt">Style</a>: Music data</li>
</ul>

</td>
<td>
<h3>Other information</h3>
<ul>
<li><a href='http://www.wangz.net/gsqlparser/sqlpp/sqlformat.htm?ref=sqlzoo'
onclick="return document.createElement('img').setAttribute('src','wangz.png')">
SQL Formatter:
</a>
Use sqlparser.com to convert any SQL into a
readable and colorful style</li>
<li><a href="/hack/">Exploit SQL Injection Attack</a>:
 Practice Hacking using an SQL Injection attack against our test system.</li>
<li><a href="http://db.grussell.org">Relational Database Theory</a>
 including a <a href="http://db.grussell.org/mc">quiz</a>.</li>
<li><a href="w.htm">What is SQL?</a></li>
<li><a href="h.htm">About SQLzoo.</a></li>
<li><a href="say.htm">How to say SQL.</a></li>
</ul>

<h3>Diversions</h3>

<ul>
<li><a href="/d2/home.html">What's the point of
trigonometry?</a></li>

<li><a href="7.htm">Top of the Pops: using dates</a></li>

<li><a href="5.htm">ACME products: dealing with money.</a></li>

<li><a href="e1.htm">Thrice Unfactorised Enigma</a></li>

<li><a href="e2.htm">Triangular or Square
Enigma</a></li>
</ul>
</td>
</tr>
</table>
<div>
[<a href="http://sqlzoo.de">SQLzoo in German</a>]
[<a href="http://sqlzoo.net/jp/">SQLzoo in Japanese 日本語</a>]
</div>
<p>By <a href="http://www.dcs.napier.ac.uk/~andrew/">Andrew Cumming</a> of
the <a href="http://www.soc.napier.ac.uk/">School of Computing</a>
of <a href="http://www.napier.ac.uk/">Napier University</a>,
Edinburgh, UK. 1999-2009</p>
<style type="text/css">
.human {background-color:rgb(192,192,192)}
.machine {background-color:rgb(240,240,240)}
</style>
<!--
<table width="100%">
<tr>
<td colspan="4" align="center" class="human">Human Translations</td>
<td colspan="3" align="center" class="machine">Machine Translation</td>
</tr>
<tr>
<td class="human"><a href="http://sqlzoo.net/sq/">Albanian</a></td>
<td class="human"><a href="http://sqlzoo.net/~peter.morcinek/">German</a></td>
<td class="human"><a href="http://sqlzoo.net/es/">Spanish</a></td>
<td class="human"><a href="http://sqlzoo.net/zh-CN/">Chinese</a></td>
<td class="machine"><a href="http://sqlzoo.net/fr/">French</a></td>
<td class="machine"><a href="http://sqlzoo.net/it/">Italian</a></td>
<td class="machine"><a href="http://sqlzoo.net/pt/">Portuguese</a></td>
</tr>
</table>
<p>Thanks to 
Dongyan Zhou, Pablo Ruiz,
<a href="http://web.f4.fhtw-berlin.de/morcinek/index.shtml">Peter Morcinek</a>
and
<a href="http://fshmn.uni-pr.edu/soft-eng/">Kujtim Hyseni</a>
</p>
-->
</body>
</html>
