0
0
SQLquery~5 mins

SELECT specific columns in SQL

Choose your learning style9 modes available
Introduction

We use SELECT specific columns to get only the data we need from a table. This makes the results easier to read and faster to get.

When you want to see only names and emails from a list of users.
When you need just the product names and prices from a product catalog.
When you want to check only the dates and amounts from sales records.
When you want to avoid showing sensitive data like passwords or personal info.
When you want to reduce the amount of data transferred for faster queries.
Syntax
SQL
SELECT column1, column2, ... FROM table_name;
List the columns you want separated by commas after SELECT.
Use the table name after FROM to tell where to get the data.
Examples
This gets only the name and email columns from the users table.
SQL
SELECT name, email FROM users;
This shows just the product names and their prices.
SQL
SELECT product_name, price FROM products;
This retrieves only the order dates and total amounts from orders.
SQL
SELECT order_date, total_amount FROM orders;
Sample Program

This query selects only the first and last names from the employees table.

SQL
SELECT first_name, last_name FROM employees;
OutputSuccess
Important Notes

If you want all columns, use SELECT * but it can be slower and harder to read.

Column names are not case sensitive but it's good to write them clearly.

You can rename columns in the output using AS, like SELECT first_name AS name.

Summary

Use SELECT specific columns to get only the data you need.

List columns separated by commas after SELECT.

This makes your queries faster and results easier to understand.