SQL 101· Level 1
SELECT and FROM
A database keeps data in tables. A table is like a spreadsheet tab: each row is one thing (a student, a unit) and each column is one fact about it.
A SQL query is a question you ask of a table. The simplest query has two parts:
SELECTsays which columns you wantFROMsays which table they come from
Put commas between columns. Use * to mean "every column". You can also calculate in a SELECT, such as credit_points * 25, and name the new column with AS.
Capital letters and line breaks do not matter to SQL, so select and SELECT do the same thing. Capitals for keywords just make a query easier to read.
Worked example
List every student's name and home state.
SELECT first_name, last_name, state FROM students
Getting the practice database ready…
This takes a few seconds the first time. Nothing leaves your computer.