MySQL Tutorial: How to Retrieve Data with SELECT

![[Mysql 강좌] 6강 SELECT로 데이터 조회하기](/uploads/editor/Mysql-%EA%B0%95%EC%A2%8C-6%EA%B0%95-SELECT%EB%A1%9C-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%A1%B0%ED%9A%8C%ED%95%98%EA%B8%B0-20260706-04e725.webp)
Now That You've Stored Data, It's Time to Verify
Last time, we used the INSERT statement to save data.
But saving data isn't the end of the process.
You need to verify that it was saved correctly,
and retrieve the necessary data for display on your screen.
This is where SQL's SELECT comes in handy.
SELECT is arguably the most frequently used command in MySQL.
What Is SELECT?
SELECT is a command for retrieving data stored in a database.
In simple terms,
a SQL statement that fetches the required data.
For example:
Viewing a list of members
Displaying board posts
Showing comments
Browsing product listings
All these features are built using the SELECT statement.
The Most Basic SELECT Statement
Let's retrieve all data from the member table.
SELECT * FROM member;
When executed, this will display all data stored in the member table.
Here,
*
refers to all columns (All Columns).
Selecting Specific Columns
You don't always need all data.
If you only want names and emails, write:
SELECT name, email
FROM member;
Selecting only necessary columns makes queries faster and keeps your code cleaner.
In professional work, it's best to get in the habit of selecting only required columns.
Example: Retrieving Board Posts
To view board posts, you can use:
SELECT title, writer, created_at
FROM board;
This SQL will display only the:
Title
Author
Date Created
This is the most common way to retrieve board listings.
How SELECT Statements Work
A SELECT statement follows this structure:
SELECT column_name
FROM table_name;
For example:
SELECT *
FROM board;
The structure is simple, making it easy to get comfortable with quickly.
Using * to Retrieve All Columns
SELECT *
FROM member;
This is convenient,
but it's not always the best practice in professional settings.
For example,
You might accidentally retrieve passwords along with other data.
Fetching unnecessary data can also impact performance.
In actual projects, selecting only required columns is crucial.
Changing Column Order
The order of columns you select can be freely changed.
SELECT
email,
name,
id
FROM member;
The results will display in the order you specified.
Performing Calculations with SELECT
SELECT can also perform calculations.
SELECT
10 + 20;
The result will be:
30
Beyond simple math, you can use various functions.
Checking the Current Date and Time
To check the current date and time, run:
SELECT NOW();
This will display output like:
2026-07-03 15:20:10
This is a very commonly used function in professional work.
Checking the Current Database
To check which database you're currently using, run:
SELECT DATABASE();
This command is very useful when working with multiple databases during practice.
Using Aliases (AS)
You can rename columns for display purposes.
SELECT
name AS 이름,
email AS 이메일
FROM member;
The output will appear as:
이름
이메일
This makes the display more user-friendly, especially when creating reports.
SELECT Retrieves Data Without Modifying It
SELECT only retrieves data.
It does not modify or delete any data.
In other words,
SELECT *
FROM member;
You can run this hundreds of times without changing the table's contents.
Retrieving data is a safe operation.
Where SELECT Is Used in Real Websites
SELECT is hidden behind most features you use on websites.
For example:
Board listings
Viewing individual posts
Comment lists
Member lists
Product catalogs
Announcements
All these features retrieve data using SELECT statements.
In fact, most information displayed on websites comes from SELECT queries.
Common Beginner Mistakes
1. Forgetting the FROM Clause
If you write like this, an error will occur:
SELECT *
member;
The FROM keyword must always be included.
2. Typing the Wrong Table Name
If you enter a non-existent table name, the query won't work.
Always double-check your table names.
3. Using Incorrect Column Names
Typing a column that doesn't exist will cause an error.
Get into the habit of checking column names with the DESC command.
4. Forgetting the Semicolon
SQL statements typically end with a semicolon (;).
This is one of the most common mistakes during practice.
Key Takeaways from This Lesson
Here are the key points to remember:
SELECT is the SQL command for retrieving data.
SELECT *retrieves all columns.You can select only necessary columns.
The
FROMclause must be followed by a table name.You can check the current date/time with
NOW().You can verify the current database with
DATABASE().SELECT does not modify data.
Since SELECT is used in almost every project, it's essential to become comfortable with it.
In Conclusion
In this lesson, you learned how to use the SELECT statement to retrieve stored data from a database.
You can now fetch the data you need, but currently, you're retrieving all data at once.
In real projects, you'll often need to find specific members, get only the latest posts, or filter data based on conditions.
In the next lesson, we'll explore how to use WHERE, ORDER BY, and LIMIT to search for and sort specific data.
FAQ
What does the * symbol mean in SQL?
The * symbol means 'all columns' in a database table. It retrieves every column of data from the specified table.
Why should I avoid using SELECT * in production code?
Using SELECT * can retrieve unnecessary data like passwords, which impacts performance and security. Always select only required columns for efficiency.
Korean Source
This article is an English localization of a Korean-language report from BlogScore. Original: [Mysql 강좌] 6강 SELECT로 데이터 조회하기