<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://sqlzoo.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://sqlzoo.net/w/index.php?title=WHERE_filters&amp;feed=atom&amp;action=history</id>
		<title>WHERE filters - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=WHERE_filters&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=WHERE_filters&amp;action=history"/>
		<updated>2013-05-24T02:53:18Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.4</generator>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=WHERE_filters&amp;diff=1024&amp;oldid=prev</id>
		<title>Connor: Created page with &quot;&lt;h3&gt;BBC Country Profiles&lt;/h3&gt; Some examples of simple &lt;code&gt;WHERE&lt;/code&gt; statements:  &lt;div class='qu'&gt; The population of &lt;code&gt;'France'.&lt;/code&gt; '''Strings should be in 'single...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=WHERE_filters&amp;diff=1024&amp;oldid=prev"/>
				<updated>2012-07-12T11:25:47Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;h3&amp;gt;BBC Country Profiles&amp;lt;/h3&amp;gt; Some examples of simple &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; statements:  &amp;lt;div class=&amp;#039;qu&amp;#039;&amp;gt; The population of &amp;lt;code&amp;gt;&amp;#039;France&amp;#039;.&amp;lt;/code&amp;gt; &amp;#039;&amp;#039;&amp;#039;Strings should be in &amp;#039;single...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;h3&amp;gt;BBC Country Profiles&amp;lt;/h3&amp;gt;&lt;br /&gt;
Some examples of simple &amp;lt;code&amp;gt;WHERE&amp;lt;/code&amp;gt; statements:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
The population of &amp;lt;code&amp;gt;'France'.&amp;lt;/code&amp;gt;&lt;br /&gt;
'''Strings should be in 'single quotes';'''&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT population FROM bbc&lt;br /&gt;
  WHERE name = 'France'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT population FROM bbc&lt;br /&gt;
  WHERE name = 'France'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
The names and population densities for the very large countries.&lt;br /&gt;
'''We can use mathematical and string expressions as well as field names and constants.'''&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT name, population/area FROM bbc&lt;br /&gt;
  WHERE area &amp;gt; 5000000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT name, population/area FROM bbc&lt;br /&gt;
  WHERE area &amp;gt; 5000000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Where to find some very small, very rich countries.&lt;br /&gt;
'''We use AND to ensure that two or more conditions hold true.'''&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT name , region&lt;br /&gt;
  FROM bbc&lt;br /&gt;
  WHERE area &amp;lt; 2000&lt;br /&gt;
    AND gdp &amp;gt; 5000000000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT name , region&lt;br /&gt;
  FROM bbc&lt;br /&gt;
  WHERE area &amp;lt; 2000&lt;br /&gt;
    AND gdp &amp;gt; 5000000000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Which of &amp;lt;code&amp;gt;Ceylon&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Iran&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Persia&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Sri Lanka&amp;lt;/code&amp;gt; is the name of a country?&lt;br /&gt;
'''The word IN allows us to check if an item is in a list.'''&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT name FROM bbc&lt;br /&gt;
  WHERE name IN ('Sri Lanka', 'Ceylon',&lt;br /&gt;
                 'Persia',    'Iran')&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT name FROM bbc&lt;br /&gt;
  WHERE name IN ('Sri Lanka', 'Ceylon',&lt;br /&gt;
                 'Persia',    'Iran')&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
What are the countries beginning with D?&lt;br /&gt;
'''The word &amp;lt;code&amp;gt;LIKE&amp;lt;/code&amp;gt; permits pattern matching - % is the wildcard.'''&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT name FROM bbc&lt;br /&gt;
  WHERE name LIKE 'D%'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT name FROM bbc&lt;br /&gt;
  WHERE name LIKE 'D%'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Which countries are not too small and not too big?&lt;br /&gt;
&amp;lt;code&amp;gt;BETWEEN&amp;lt;/code&amp;gt; allows range checking - note that it is inclusive. &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT name, area FROM bbc&lt;br /&gt;
  WHERE area BETWEEN 207600 AND 244820&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT name, area FROM bbc&lt;br /&gt;
  WHERE area BETWEEN 207600 AND 244820&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SELECT attribute-list&lt;br /&gt;
   FROM table-name&lt;br /&gt;
   WHERE condition&amp;lt;/pre&amp;gt;&lt;br /&gt;
  &amp;lt;ul&amp;gt;&lt;br /&gt;
    &amp;lt;li&amp;gt;&lt;br /&gt;
      &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;attribute-list&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;li style=&amp;quot;list-style: none&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;ul&amp;gt;&lt;br /&gt;
        &amp;lt;li&amp;gt;This is usually a comma separated list of attributes&lt;br /&gt;
        (field names)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;Expressions involving these attributes may be used. The&lt;br /&gt;
        normal mathematical operators &amp;lt;code&amp;gt;+, -, *, /&amp;lt;/code&amp;gt; may be used on&lt;br /&gt;
        numeric values. String values may be concatenated using&lt;br /&gt;
        &amp;lt;code&amp;gt;||&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;To select all attributes use *&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;The attributes in this case are: &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;region&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;area&amp;lt;/code&amp;gt;,&lt;br /&gt;
        &amp;lt;code&amp;gt;population&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;gdp&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ul&amp;gt;&lt;br /&gt;
    &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;li&amp;gt;&lt;br /&gt;
      &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;table-name&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
      &amp;lt;ul style=&amp;quot;list-style-type: circle&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;li&amp;gt;In these examples the table is always &amp;lt;code&amp;gt;bbc&amp;lt;/code&amp;gt;.&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ul&amp;gt;&lt;br /&gt;
    &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;li&amp;gt;&lt;br /&gt;
      &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;condition&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;li style=&amp;quot;list-style: none&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;ul&amp;gt;&lt;br /&gt;
        &amp;lt;li&amp;gt;This is a boolean expression which each row must&lt;br /&gt;
        satisfy.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;Operators which may be used include &amp;lt;code&amp;gt;AND&amp;lt;/code&amp;gt;,&lt;br /&gt;
        &amp;lt;code&amp;gt;OR&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NOT&amp;lt;/code&amp;gt;, &amp;amp;gt;,&lt;br /&gt;
        &amp;amp;gt;=, =, &amp;amp;lt;, &amp;amp;lt;=&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;The &amp;lt;code&amp;gt;LIKE&amp;lt;/code&amp;gt; operator permits strings to be compared using&lt;br /&gt;
        'wild cards'. The symbols _ and % are used to represent a&lt;br /&gt;
        single character or a sequence of characters. Note that &amp;lt;code&amp;gt;MS&lt;br /&gt;
        Access SQL&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;?&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;_&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;%&amp;lt;/code&amp;gt; .&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;The &amp;lt;code&amp;gt;IN&amp;lt;/code&amp;gt; operator allows an item to be tested against a&lt;br /&gt;
        list of values.&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;li&amp;gt;There is a &amp;lt;code&amp;gt;BETWEEN&amp;lt;/code&amp;gt; operator for checking ranges.&amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;/ul&amp;gt;&lt;br /&gt;
    &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;/ul&amp;gt;&lt;/div&gt;</summary>
		<author><name>Connor</name></author>	</entry>

	</feed>