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
*expands to every column, in the table's declared order.o.*takes every column from one table in a join.- Naming the columns you want survives an
ALTER TABLEthat adds one.
Keywords and builtins used here
ASFROMJOINONSELECTc
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.
Step 2 of 5 in Selecting rows, step 2 of 23 in Language basics.