Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Viewing and Sorting Data in MySQL

When working with databases, one of the most important skills is knowing how to view and arrange data to gain useful information. MySQL provides several ways to query databases in order to accomplish this. In this lab, we will run several queries in order to produce specific output.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 20, 2025
Duration
1h 15m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    List All of the Rows in the `orders` and `products` Tables (run a single query for each)

    Login to the MySQL server and change to the prod database:

    [cloud_user@host]$ mysql -u root -p
    
    mysql> USE prod;
    

    Run the following query to list the rows in the orders table:

    mysql> SELECT * FROM orders;
    

    Run the following query to list the rows in the products table:

    mysql> SELECT * FROM products;
    
  2. Challenge

    Run a Query on the `orders` Table to Order the Rows by the `purchaseDate` Column in Ascending Order

    Run the following query on the orders table:

    mysql> SELECT * FROM orders ORDER BY purchaseDate;
    
  3. Challenge

    Run a Query on the Orders Table That Shows All the Names Beginning with the Letter “m”

    Run the following query to show all the orders where the name begins with “m”:

    mysql> SELECT * FROM orders WHERE name LIKE 'm%';
    
  4. Challenge

    Run a Query on the `orders` Table That Shows All Purchases in 2018 Where the `productID` Is Less Than 4

    Run the following query to show all purchases from 2018 where the productID is less than 4:

    mysql> SELECT * FROM orders WHERE purchaseDate LIKE '2018%' AND productID < 4;
    
  5. Challenge

    Run a Query on the `products` Table so That the Output Is in Alphabetical Order Based on the `type` Column

    Run the following query on the products table so that the output is in alphabetical order:

    mysql> SELECT * FROM products ORDER BY type;
    
  6. Challenge

    Run a Query on the `products` Table Where the Cost Is More Than or Equal to 1000

    Run the following query to show where the cost is greater or equal to 1000:

    mysql> SELECT * FROM products WHERE cost >= 1000;
    
  7. Challenge

    Run a Query on the `products` Table That Shows Output Where the Cost Is Greater Than 2000 or Less Than 500

    Run the following query to show the items where cost is greater than 2000 or less than 500:

    mysql> SELECT * FROM products WHERE cost > 2000 OR cost < 500;
    
  8. Challenge

    Show `orders.name`, `products.type`, and `products.cost` By Performing an Inner Join between `orders` and `products` Using `orders.productID` and `products.id`

    Run the following command to perform an INNER JOIN on the orders and products table:

    mysql> SELECT orders.name, products.type, products.cost FROM orders INNER JOIN products WHERE orders.productID = products.id;
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight