Objectives

Students will be able to:

  • Read, understand and complete structured query language (SQL) scripts to query data stored in a single database table
  • understand key terms: SELECT, FROM, WHERE, ORDERBY, SUM, COUNT
  • Identifying the output given by an SQL statement that will query the given contents of a database table

SQL

SQL is a kind of programming language which commonly allows web pages to communicate with a database on a web server!

    SQL Crash Course

Watch this video for a crash course in SQL - STRUCTURED QUERY LANGUAGE

    Video Review

The above table of data, favourites has 7 fields and 28 records.

The datatype of most of the fields is TEXT... or STRING

But one of the fields has a datatype of NUMBER... or INTEGER.

Complete the following queries and check if you are right!

    Video Review

Complete the following queries and check if you are right!

SQL Query 1

The following query will select the Location from the favourites table for everyone who is older than 20:

SELECT

FROM

WHERE

SQL Query 2

The following query will select the Favourite Food and Favourite TV Channel of all people aged between 17 and 23 inclusive

SELECT Favourite Food,

FROM

WHERE age>=17 and

SQL Query 3

The following query will display a count of all people from the USA.

SELECT

FROM favourites

WHERE

SQL Query 4

The following query will display the ID and Location of all people from USA or UK or Singapore in ascending order of Location.

SELECT , Location

FROM favourites

WHERE OR OR

ORDER BY ASC

Food For Thought

SQL allows a webpage to communicate with a database on a web server. I wonder if it is possible for that database to have more than one table? Or do we need more than one database?!




essential vocabulary

SELECTcriteriacondition double FROM query integer WHERE SQL datatype ORDER BY * COUNT SUM


SUBSCRIBE

Join my mailing list to receive updates on the latest blog posts and other things.