Home › Learn › SQL › Reading rows

Choosing columns

Lesson 2 of 26. Ask for only the columns you need, in the order you want them.

Instead of *, list the columns you want, separated by commas: SELECT name, price FROM products;. The result has exactly those columns, in the order you wrote them. Asking for only what you need makes results readable and, on big tables, much faster.

Column names are the ones in the table definition. If you misspell one, the database says no such column, which is the most common error you will see in this course.

SELECT name, dept FROM employees;

Your task

Show the name and price of every product, in that order.

Hint 1

Replace ... with the two column names separated by a comma.

Show the solution
SELECT name, price FROM products;

    Runs SQLite compiled to WebAssembly in this tab; the database is rebuilt before every run.