Difference between revisions of "SELECT names"

From SQLZOO
Jump to: navigation, search
Line 26: Line 26:
 
    
 
    
 
<div class='qu'>
 
<div class='qu'>
The clause '''name LIKE 'B%' ''' finds those countries that start with "B".
+
You can use <code>WHERE name LIKE 'B%'</code> finds those countries that start with "B".
 
*The % is a ''wild-card'' it can match any characters
 
*The % is a ''wild-card'' it can match any characters
 
<p class='imper'>Find the country that start with Y</p>
 
<p class='imper'>Find the country that start with Y</p>

Revision as of 20:52, 20 November 2014

namecontinent
AfghanistanAsia
AlbaniaEurope
AlgeriaAfrica
AndorraEurope
AngolaAfrica
....

Pattern Matching Strings

This tutorial uses the LIKE operator to check names. We will be using the SELECT command on the table world:

Summary

You can use WHERE name LIKE 'B%' finds those countries that start with "B".

  • The % is a wild-card it can match any characters

Find the country that start with Y

SELECT name FROM world
  WHERE name LIKE 'F%'
SELECT name FROM world
  WHERE name LIKE 'Y%'