BBampaa

Lessons › SQL › Chapter 1: Reading data

SQL lesson

SELECT specific columns

Instead of *, write the names of the columns you want. Only those come back, and every row stays. Put a comma between the names. They come back in the order you write them.

Try this lesson free →
About 5–10 minutes · no sign-up needed

Example

Pick the columns you need

SELECT product_id, price
FROM products

Result:

product_idprice
P2001299.99
P200249.95
P200322.5
P2004134.0
P200589.75

Step by step

  1. List the columns you want after SELECT. Only those come back.
    SELECT product_id, price FROM products
  2. A comma goes between column names. No comma after the last one.
    SELECT product_id, price FROM products
  3. Columns come back in the order you list them.
    SELECT product_id, price FROM products

Practice

Try each one in your head first, then open the answer.

1. Using the orders table, write a query to show only the order_date and category columns.
SELECT order_date, category FROM orders
2. Using the products table, write a query to show only the brand and category columns.
SELECT brand, category FROM products
3. Using the customers table, write a query to show only the signup_date and email columns.
SELECT signup_date, email FROM customers
4. Using the inventory table, write a query to show only the stock_count and warehouse columns.
SELECT stock_count, warehouse FROM inventory
5. Using the returns table, write a query to show only the return_id and refund_amount columns.
SELECT return_id, refund_amount FROM returns

Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.

Try this lesson free →
About 5–10 minutes · no sign-up needed