sql tutorial · Beginner
Pull rows and columns out of a table, filter them with WHERE, sort with ORDER BY, and cap the results with LIMIT.
Every query starts with SELECT (which columns you want) and FROM (which table they live in). * means every column.
Press Run (or Ctrl+Enter) to see every customer in the shop.
In real code, list the columns you need instead of using *. It makes the query easier to read, and it won't break or slow down when someone adds a column later.
WHERE keeps only the rows that match a condition. Text values go in single quotes. Combine conditions with AND and OR.
ORDER BY sorts the results (DESC for largest first), and LIMIT caps how many rows come back. Without ORDER BY, Postgres can return rows in any order it likes.
exercise List the name and price of every product that costs less than $30, cheapest first.