SQL SELECT Statement
Chapter 3 of 40 · Estimated read time: 7 min
The SELECT statement is the most used SQL command. It retrieves data from one or more tables. The result is returned as a temporary result set called the result-set.
Syntax
SELECT column1, column2, ...
FROM table_name;
Example 1 — Select Specific Columns
Select only the product name and price from the products table:
SELECT product_name, price FROM products;
OUTPUT ↓
| product_name | price |
|---|---|
| Wireless Mouse | 899 |
| USB-C Hub | 1499 |
| Notebook A5 | 99 |
| Ballpoint Pens | 49 |
| Desk Lamp | 1199 |
| Ergonomic Chair | 8999 |
| HDMI Cable | 299 |
Example 2 — Select All Columns with *
Use * (asterisk) to select every column in the table:
SELECT * FROM products;
Avoid SELECT * in production queries. It is fine for quick exploration, but in real applications always name the columns you need — it makes queries faster, more readable, and less likely to break when the table schema changes.
Example 3 — Expressions and Calculations
You can calculate new values directly in SELECT:
-- Price including 18% GST SELECT product_name, price, price * 1.18 AS price_with_gst, stock * price AS inventory_value FROM products;
OUTPUT ↓
| product_name | price | price_with_gst | inventory_value |
|---|---|---|---|
| Wireless Mouse | 899 | 1060.82 | 134850 |
| USB-C Hub | 1499 | 1768.82 | 119920 |
| Notebook A5 | 99 | 116.82 | 49500 |
| Ergonomic Chair | 8999 | 10618.82 | 179980 |
AS gives a column a new name (alias) in the result. You will learn more about aliases in the Aliases chapter.
Example 4 — Select a Literal Value
You can select constant values — useful for adding a fixed label column:
SELECT product_name, price, 'INR' AS currency, 'In Stock' AS status FROM products WHERE stock > 0;
Example 5 — Combine Strings (Concatenation)
-- PostgreSQL / BigQuery: use ||
SELECT
customer_name || ' (' || city || ')' AS customer_with_city
FROM customers;
-- MySQL: use CONCAT()
SELECT
CONCAT(customer_name, ' (', city, ')') AS customer_with_city
FROM customers;OUTPUT ↓
| customer_with_city |
|---|
| Amit Verma (Noida) |
| Priya Sharma (Delhi) |
| Rohan Mehta (Mumbai) |
| Sneha Gupta (Noida) |
| Arjun Singh (Bengaluru) |
✏️ Practice Exercises
1. Write a query to select only customer_name and city from the customers table.
2. Select product_name, price, and a calculated column showing the price after a 10% discount.
3. Select all orders where the total_amount column is shown in thousands (divide by 1000).
Show Answers
-- 1. SELECT customer_name, city FROM customers; -- 2. SELECT product_name, price, price * 0.90 AS discounted_price FROM products; -- 3. SELECT order_id, customer_id, total_amount / 1000.0 AS amount_k FROM orders;