SQLTeam.com | Weblogs | Forums

Novice learning SQL: help with sql code


Show the countries which have a name that includes the word 'United'
in a table

this code does not work what do I need to change, it should return
United Arab Emirates
United Kingdom
United States


Use the LIKE operator


FROM world
WHERE name like 'United%'

Note that '*' is not a wildcard character according to the SQL standard


Note that

name like 'United%'

will match country names that START with "United", whereas if you want INCLUDES you would need to do:

name like '%United%'

Beware that putting the wildcard ("%") at the start can have significant performance implications compared to only putting it at the end. On a small database it is unlikely to make any noticeable difference, but as the database size grows it can be an issue.


Show the countries that are big by area or big by population. Show name, population and area. country is big if it has an area of more than 3 million sq km or it has a population of more than 250 million.

select name, population, area from world
if population >25000000 or area > 3000000


Change IF to WHERE


Do you have a good guide to basic SQL Syntax? here's one. SQL cheat sheet


sorry guys I am a total novice to SQl, all this is new,
I am learning SQL and determined to get better. I have a book and I am also learning online.
thank you for all your help so far, I know these questions can be trying


Don't worry, we've got no problem with Newbie questions. Only requirement is that you show what you have one so far - because if we do it all for Students then they won't learn anything :slightly_smiling: but you've done that, so all is fine and dandy :sunny: