Home / Learn Secure SQL / SELECT: Reading Rows

SELECT: Reading Rows

The first and most-used SQL statement.

The gistThe first and most-used SQL statement.

The idea, explained simply

AnatomySELECT columnsFROM tableWHERE filterORDER BYLIMIT
Anatomy

What it is

SELECT reads rows from one or more tables, optionally choosing only some columns and some rows.

Why it matters

Almost every feature in a web app starts with reading data: a profile page, a search box, a report.

Mechanically speaking

Name the columns you need (never more than that), name the table, and optionally filter and sort.

Shows up in

  • Web application code review
  • Backend development
  • Database administration
Basic SELECTSQL: edit and run

Only the columns you actually need are listed, which also protects you from accidentally exposing a column you added later.

Check yourself

1. Best practice for columns in SELECT?