MYSQL
June 3, 2026 2 min read

Data Retrieval in MYSQL: Mastering Select Queries for Fetching and Filtering Records

HS
HEMANT SINGH
Technical Writer & Educator

The select query is used to fetch records from a table, whenever you have the requirement to display or calculate some data from the table data, select query will be used.

For this query command, we will use the given table as an example.

Table name: users

idfirst_namelast_nameemail
1RamSinghRam89@gmail.com
2KrishnaSinghKrishna90@gmail.com

 

Select all records with all columns (Properties)

There are two ways to write a query

  • Without writing all the column names (using *)
  • With writing all the column names

Without writing all column names (using *)

SELECT * FROM users;

Table name: users

idfirst_namelast_nameemail
1RamSinghRam89@gmail.com
2KrishnaSinghKrishna90@gmail.com

With writing all column names

SELECT id, first_name, last_name, email FROM users;

Table name: users

idfirst_namelast_nameemail
1RamSinghRam89@gmail.com
2KrishnaSinghKrishna90@gmail.com

Fetch all records with specific columns

Select id, first_name, email FROM users;
idfirst_nameemail
1RamRam89@gmail.com
2KrishnaKrishna90@gmail.com

Fetch specific records (WHERE clause)

WHERE clause is used to filter records from the table, or it is used whenever we want to fetch records from the table with the conditions.

SELECT * FROM users WHERE id < 2;

In this query command, we are fetching only those records which have an id value less than 2.

Table name: users

idfirst_namelast_nameemail
1RamSinghRam89@gmail.com