#2 SQL

Where Clause

We often select only a portion of out huge database. For example, we will use table from last article and we would like to select only students with bikes. Let’s do it.

idnamesurnamedate_of_birthhas_bicycle
1JohnSmith1995/05/15true
2AlexHunnybun2004/01/19false
3CarolGladden2005/10/13true
SELECT id FROM students WHERE has_bicycle = true;

The result:

id
1
3

Examples of another where clause uses:

SELECT * FROM students WHERE surname = 'Smith';
SELECT * FROM students WHERE id = 1;
SELECT * FROM students WHERE date_of_birth < '2005/01/01';

Pridaj komentár

Vaša e-mailová adresa nebude zverejnená. Vyžadované polia sú označené *