Running SQL queries on a database with phpMyAdmin Print

  • 211

This article is to teach you how to run SQL queries on a database with phpMyAdmin. We will be expecting that you are at this time signed into phpMyAdmin, and for the purpose of this article, 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 enumerated. Directly below the database, you will find the lists 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 initial thing you need to do is click on the 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 article, "Deleting fields from database tables with phpMyAdmin", you can erase 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 article, you are going to learn how to erase a field using all 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 erase the field from the table into the box. It would appear 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 you really want to do the action. Click OK. The command screen will next confirm that your SQL query has been successful. You have actually removed a field from a table.

For additional 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 last part of this article. You now know how to run a SQL query on a database using phpMyAdmin.


Was this answer helpful?

« Back