Aral Code

Getting Started Lesson 3 of 21

SQL SELECT — Choosing Columns

Read data with SELECT and FROM, choose specific columns, compute new columns with math, and follow SQL's formatting rules.

SELECT is the command you'll use most. It reads data from a table and shows it as a result table. You choose which columns you want, and later lessons show how to choose which rows.

Syntax

SELECT column1, column2, ...
FROM table_name;

Selecting all columns

SQL Everything from customers
SELECT * FROM customers;

The asterisk * means "all columns". It's convenient for exploring, but in real applications you should list only the columns you need. It's faster and clearer.

Selecting specific columns

SQL Just names and prices
SELECT name, price FROM products;

Columns appear in the order you list them. Try SELECT price, name, stock FROM products;.

Calculations

You can compute new values in a SELECT. These don't change the table; they're only in the result:

SQL Value of the stock on the shelf
SELECT name, price, stock, price * stock
FROM products;

price * stock is how much money all of that item on the shelf is worth. You can use +, -, *, / and parentheses, just like in math.

Naming computed columns with AS

The column title price * stock is ugly. Give it a name with AS:

SQL Using AS for a clear column name
SELECT name,
       price AS old_price,
       price * 1.10 AS new_price
FROM products;

A name given with AS is called an alias. There's a whole lesson on aliases later.

Joining text

In SQLite and standard SQL, || joins text together:

SQL Full names
SELECT first_name || ' ' || last_name AS full_name, grade, section
FROM students;

In MySQL, you'd write CONCAT(first_name, ' ', last_name) instead.

SQL formatting rules

  • Keywords aren't case-sensitive: SELECT, select and Select all work. Writing keywords in UPPERCASE is a common habit because it makes queries easier to read.
  • Spaces and new lines don't matter: put each part (SELECT, FROM, WHERE…) on its own line for readability.
  • End each statement with a semicolon ;. It's required when running several statements together.
  • Text values use single quotes: 'Bread', not "Bread".

Comments in SQL

SQL Comments are ignored
-- This is a single-line comment
SELECT name, stock   /* a comment can go here too */
FROM products;

Running more than one query

Separate queries with semicolons. Our editor shows each result one after another:

SQL Two queries at once
SELECT name FROM customers;
SELECT name FROM products;

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. Which query shows only the name and phone of customers?
2. What does AS do in price * 2 AS double_price?
3. Does SELECT price * 2 FROM products change the prices in the table?
4. Which quotes are used for text values in SQL?

By Sir Reyel · Last updated 2026-12-04