The shape of a query
SQL (Structured Query Language) is the language used to ask a database for data. A question written in SQL is called a query.
`SELECT` lists the fields you want to see. `FROM` names the table. `WHERE` gives the condition a record must meet.
The output is a new, smaller table. It has only the chosen fields, and only the records that meet the condition.
| Symbol | Meaning | Example |
|---|---|---|
| = | equal to | Station = 'Sol' |
| <> | not equal to | BikeType <> 'E' |
| > | greater than | Minutes > 30 |
| < | less than | Cost < 1.00 |
| >= | greater than or equal to | Minutes >= 30 |
| <= | less than or equal to | Cost <= 2.00 |
SELECT HireID, Station FROM BikeHire WHERE Minutes > 30;
Text values go inside single quotes, like `'Sol'`, so SQL knows where the text starts and ends. Numbers and TRUE/FALSE have no quotes.