Module 01 · lesson 1
SELECT and FROM: getting data out
The founder wants to do a stock-take — to see all the products at once. The quickest way is to pull the whole table with a single query. That's where we'll begin the module on reading data.
SELECT and FROM — the two halves of a query
Almost every read query is SELECT (what to show) + FROM (where to take it from). Together:
SELECT *
FROM <table>;
For example
SELECT *
FROM users;
SELECT— "pick";*— "all columns";FROM products— "from theproductstable".
The order is always the same: SELECT first, then FROM.
* (all columns) is fine for a quick look. But in real queries it's better to list only the columns you need — so you don't drag along extra data (more on this in the next lesson).
Your turn
Write a query that outputs the whole products table.
Summary
SELECT * FROM <table>returns the whole table — the basic form of reading that everything starts from.SELECT— what to show,FROM— where to take it from.*means all columns.- Order:
SELECTbeforeFROM.