Using Queries to Interact With Your MySQL Database

This is a free resource from my online course, From Idea To Launch, where I teach you how to build a full Laravel web application, step by step, at beginner's speed. Learn more →

To practice your new MySQL skills, you’re going to run a few additional queries on your new [objects] database table in your fitl database.

You can run all of the queries below in the phpMyAdmin interface. And make sure you use the Common MySQL Queries & Query Commands Cheatsheet for reference!


1. Selecting specific pieces of information

Pick two of your [objects] table’s columns.

Write a query to retrieve all your objects, selecting only those two columns’ values.

2. Select all objects using a string comparison

Pick one of the VARCHAR or TEXT columns in your [objects] table.

Pick a word, or phrase, contained in that value of column for one or more of your objects. (E.g. I have a title column; my first object’s title is 'I need help with a JavaScript alert', so I might choose the word alert.)

Then write a query to select all of your objects that contain that chosen string. (Hint: use the LIKE operator.)

3. Insert a new object using a query

Use an INSERT query to insert a new, third object with all required pieces of information.

4. Delete that new object

Sorry! It’s time to delete your new object.

Run a DELETE query to remove the newly-inserted, third object, referencing its id value.

5. Update your first object

Using the same column you chose for #2, let’s call it [column_x]

Write a query to alter your first object’s [column_x] value.