typestar

SELECT star in SQL

The star is fine at a prompt and a liability in code that has to keep working.

SELECT *
FROM products;

SELECT
    o.*,
    c.name
FROM orders AS o
JOIN customers AS c
    ON c.id = o.customer_id;

How it works

  1. * expands to every column, in the table's declared order.
  2. o.* takes every column from one table in a join.
  3. Naming the columns you want survives an ALTER TABLE that adds one.

Keywords and builtins used here

The run, in numbers

Lines
9
Characters to type
105
Tokens
30
Three-star pace
70 tpm

At the three-star pace of 70 tokens a minute, this run takes about 26 seconds.

Type this snippet

Step 2 of 5 in Selecting rows, step 2 of 23 in Language basics.

← Previous Next →