SELECT and FROM — the simplest query
Pick the fields, name the table.
Every SQL query starts with SELECT and FROM.
Pattern:
SELECT field1, field2
FROM tableName;
Examples (from a Books table with fields BookID, Title, Author, Year, Price):
-- Show every book's title and author
SELECT Title, Author
FROM Books;
-- Show ALL fields for every book
SELECT *
FROM Books;
The asterisk * means 'all fields'. Use it when you want everything; otherwise list the specific fields needed (uses less bandwidth, makes intent clearer).
Cambridge tip. Keywords (SELECT, FROM, WHERE, ORDER BY) are conventionally CAPITALISED; field/table names follow the database's casing. SQL is case-insensitive in keywords.
- SELECT fields FROM table.
- = all fields.
- Capitalise SQL keywords.