MySQL for Beginners: Querying & Sorting Data (Part-6)

Tamanna shaikh
3 min readMay 8, 2024

--

Welcome to the world of databases, where we speak to our data through a language called SQL! This blog is part of the “MySQL for Beginners” series, and today, we’re going to dive into the basics of querying and sorting data in MySQL.

Introduction to MySQL Querying Data

MySQL is like a big, organized filing cabinet where all your data is stored in neat drawers called tables. To talk to this data, we use SQL, which stands for Structured Query Language. It’s like learning the secret code to ask the filing cabinet exactly what you want to know!

Photo by Caspar Camille Rubin on Unsplash

In this blog, we’ll cover:

  • SELECT FROM: It’s like asking the filing cabinet to open a specific drawer and show you all the files inside.
  • SELECT: This is when you ask to see something without opening any drawers, like asking for a sticky note left on the cabinet.
  • Sorting Data ORDER BY: Imagine you want your files not just handed to you but arranged in a certain order — that’s what sorting is all about!

Let’s get started and make sure to follow along with examples that will make you a querying pro in no time!

1) SELECT FROM — Chatting with One or More Drawers

Select * FROM employees;

or

Select emp_no,emp_name,emp_age,emp_dept FROM employees;

This is like saying, “Hey filing cabinet, can I see everything in the ‘employees’ drawer?” And it happily shows you all the files.

2) SELECT — The Magic Sticky Note

SELECT CURRENT_DATE;

No drawer needed here! You’re just asking for today’s date, which is like a note stuck on the outside of the cabinet.

3) Sorting Data ORDER BY — Line ’Em Up!

SELECT * FROM employees ORDER BY last_name ASC;

SELECT * FROM employees ORDER BY last_name DSC;

Now you’re asking for the ‘employees’ files but in a specific order — sorted by last name from A to Z or Z to A.

Why Is This Important?

Learning to query with MySQL is like learning to find your favorite toy in a huge toy box. It saves time and makes sure you get exactly what you want. Plus, it’s a super important skill for managing all kinds of data in the digital world!

Conclusion:

We’ve covered how to ask our data filing cabinet to show us things and how to get our data in the order we want. Remember, this is just the beginning of our MySQL journey. Stay tuned for more in the “MySQL for Beginners” series!

If you found this post helpful, don’t forget to 👏 clap and follow me on medium as well as on LinkedIn for more insights.

“In the world of databases, the best question always gets the best answer.”

Keep querying, and see you next time!😊

--

--

Tamanna shaikh

IT pro with 10+ years' experience in SQL & ERP. Also, explore Tech & AI together! LinkedIn: https://www.linkedin.com/in/tamanna-s-17705a84/