Running SQL Queries on a Database with PhpMyAdmin

Reading Time: 3 minutes

In this tutorial, we will explore how to run SQL queries on a database within PhpMyAdmin. SQL stands for Structured Query Language. SQL statements or queries are used to perform database tasks such as searching, updating, or retrieving data from a database.

Running SQL Queries on a Database with PhpMyAdmin

PhpMyAdmin is an open-source, web-based database administration interface used to interact with databases on a server. This guide assumes that you have already logged in to PhpMyAdmin. Now let's explore how to run SQL queries on a database.

Home_Page

To begin with, we will select the database table we wish to run an SQL query on from the left-side menu. The database name we will be using is called lwtest_wpdb.

Click_on_Database_Name

Once we select the database, we will see the database expand to show the tables within. To run a query, we will click on the SQL tab seen below.

SQL_Tab

This will open up a blank SQL query window. In this window, we can type in and run a query against the database or table.

SQL_Query

If we need help building a query, we recommend clicking on the table name in the left menu. In this case we will select the wp_comments table.

Click_on_Table_Name

Then, we will again click on the SQL tab on this page.

Table_SQL_Tab

This is similar to the SQL page we saw previously, but now it has several buttons below the query box with which we can quickly set up an example query.

Table_SQL_Buttons

Additionally, we can quickly select a single or multiple table Columns from the window on the right. Clicking on the "<<" or Insert button will add those columns to the search query without us having to memorize the column name or refer to another page.

Table_SQL_Column_Add

Next, to complete our query, we have added "< 400", to select all the comments where the ID is less than 400. Then, to run the query, we will press the "Go" button in the lower right-hand corner of the window.

Table_SQL_Go_Button

Our query results are now displayed. In this case, it shows 267 records which matched our query.

Query_Results

If we want to modify the query further, we can click on the “Show query box” text above the query results and the same query window will reopen, so we can continue modifying the query further.

Conclusion

From the PhpMyAdmin interface, we can navigate to the SQL tab on either the database or the table and build the queries we want from there. PhpMyAdmin can assist us by giving starter queries we can modify, help us add column names, view the results, and then allow us to tweak the query further. This makes the process easier to get started and visualize compared to running queries manually via a command line interface.

How Can We Help?

Our Support Teams are filled with talented individuals with intimate knowledge of web hosting technologies, especially those discussed in this article.

If you are uncomfortable walking through the steps outlined above, give us a call at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Technicians or an experienced Hosting Advisors today!

Series Navigation
<< Previous ArticleNext Article >>
Avatar for Alex Gorzen

About the Author: Alex Gorzen

Alex Gorzen has been helping others with technology his whole life. He played with computers even before he could read and wants to make sure his children share that same love as they grow up. In his free time, he enjoys gardening, building things, and learning new skills.

Latest Articles

Blocking IP or whitelisting IP addresses with UFW

Read Article

CentOS Linux 7 end of life migrations

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article