SELECT is the part of a SQL query that names the columns to retrieve. Combined with FROM, it identifies the data source; combined with WHERE, it returns only rows matching stated conditions. SQL is declarative: you describe what you want, while the RDBMS determines how to retrieve it. section 1.5 section 1.12
Build a basic SELECT query in this order:
- Write SELECT, then list one or more columns separated by commas. section 1.5 section 1.7
- Write FROM and name the table that supplies the data. section 1.5
- Add WHERE when you need to filter rows by numeric, string, or combined conditions. section 1.5 section 1.7
- Use * after SELECT to request every column, and finish the query with a semicolon. section 1.5 section 1.7
Retrieve affordable products
To return product names and descriptions for products priced below 30, write: SELECT name, description FROM product WHERE price < 30; The SELECT list chooses the two columns, FROM chooses product, and WHERE keeps only rows meeting the price condition. section 1.7
SELECT name FROM product WHERE price > 20;
View the complete three-clause query for selecting expensive product names. section 1.5




