Querying data (single table, joins, and so on)
Now that we have data in the database, we need to have a way to get that data back out. In SQL, this is done by using the SELECT
statement. It's a very versatile command, so there's no way that it can be covered completely in a single chapter. Instead, we'll go over some simple commands, and you can explore the commands more on your own.
Note
The snippets in this section are located at snippets/08/ex5-select-data/
in the code package of this book. When using the interactive snippet playground, select 8: Web SQL Database and Example 5.
At its simplest, a SELECT
statement looks as follows:
SELECT fieldName[, ...] FROM tableName[, ...] [WHERE condition[ ...]] [ORDER BY field [direction], ...]
Tip
There's a whole lot more you can do with the SELECT
statement than this, but this will suffice for now.
If we wanted to select all our definitions, we could write this command:
SELECT wordNetRef, partOfSpeech, gloss FROM definition
As you can see, WHERE
and...