Running SQL queries on a database with phpMyAdmin

This tutorial is to teach you how to run SQL queries on a database with phpMyAdmin. We will assume that you are currently logged into phpMyAdmin, and for the purpose of this tutorial, we will use a database with two tables as our example. The phpMyAdmin main screen is broken into two sections. The left hand side is blue, and this is where you will find your database listed. Below the database, you will see the names of the tables that are in the database. The right hand side is a large white window, and this is where the activity takes place.

To run SQL queries on a database, the first thing you need to do is click the on the name of the database table that you want to run a SQL query on. This opens the table details in the right hand window. As you learned in another tutorial, "Deleting fields from database tables with phpMyAdmin", you can delete a field from a table by checking the box in the field row, and clicking on the Delete icon (the big red X below the table). In this tutorial, you are going to learn how to delete a field using pure SQL commands.

Go to the right hand side and click on the database name. This will bring up the details for the database in the right hand window. Click the SQL button at the top of the window. This opens a box, titled "Run SQL query/queries on database. You will then need to type the SQL command to delete the field from the table into the box. It would look something like this: ALTER TABLE 'this is where the name of the table goes' DROP 'this is where the name of the field goes' . Then when you are done, you click on Go. A pop-up will ask if really want to perform the action. Click OK. The command screen will then confirm that your SQL query has been successful. You have just deleted a field from a table.

For more information about SQL syntax, visit the MySQL documentation available here. Just click on the icon under the phpMyAdmin name, that has the red SQL on it. This is the end of this tutorial. You now know how to run a SQL query on a database using phpMyAdmin.

  • 24 användare blev hjälpta av detta svar
Hjälpte svaret dig?

Relaterade artiklar

Becoming familiar with databases in phpMyAdmin

This tutorial is going to help you become more familiar with databases and phpMyAdmin. We are...

Copying a database table with phpMyAdmin

This tutorial is going to teach you how to copy a database table with phpMyAdmin. For the...

Creating tables in a database with phpMyAdmin

This tutorial is going to teach you how to create a table in a database with phpMyAdmin. We are...

Deleting fields from database tables with phpMyAdmin

This tutorial is going to teach you how to delete fields from database tables using phpMyAdmin....

Exporting databases and tables with phpMyAdmin

This tutorial is to teach you how to export databases and tables with phpMyAdmin. We will assume...