Sitemap
SQL Explained

SQL Explained is your go-to publication for mastering SQL, from basics to advanced queries. Learn best practices, optimizations, and real-world applications through clear, concise, and practical insights. Perfect for beginners and experts alike! 🚀 #SQL #Data

Member-only story

SQL Basics for Everyone — Part 2: SQL Select with Examples 🔦

--

Press enter or click to view image in full size
Photo by Beth Macdonald on Unsplash

The SELECT statement allows you to retrieve data from one or more tables.

The most basic SELECT Query contains two essential SQL keywords: SELECT followed by FROM.

SELECT column1, column2, ...
FROM table_name;

🔸SELECT tells the database that you want to output data, and is followed by the specific names of the columns you wish the database to print out.

🔸FROM tells the database which specific table contains that data we want to output.

🔸When evaluating the SELECT statement, the database system evaluates the FROM clause first and then the SELECT clause.

🔸The semicolon (;) is not part of a query. The database server uses the semicolon to separate two SQL statements.

👉 For example, if you execute two SELECT statements, you need to separate them using a semicolon (;)

If you want to retrieve data from all the columns of the table, you can list all the columns in the SELECT clause like this:

SELECT
column1,
column2,
column3
FROM
table_name;

Alternatively, you can use the star (*) operator as the shorthand for all columns:

SELECT * FROM table_name;

--

--

Shaloo Mathew
Shaloo Mathew

Written by Shaloo Mathew

I love working with data and finding the stories it tells. Through analytics and technology, I aim to turn data into useful insights.

SQL Explained
SQL Explained

Published in SQL Explained

SQL Explained is your go-to publication for mastering SQL, from basics to advanced queries. Learn best practices, optimizations, and real-world applications through clear, concise, and practical insights. Perfect for beginners and experts alike! 🚀 #SQL #Data