We can execute SQL Statements to our MySQL Database through PhpMyAdmin. Remember that most of the actions we perform right through the GUI, translate into SQL Statements automatically
Let's take a look at an example of that in action. Expand the MyWebsite database and click on the users table.
Just by clicking on the users table PhpMyAdmin has automatically executed a SQL Select statement, as seen here.
The SQL select statement, retrieves records from a table within a specified database. In this case "users".
We have one record in this table.
Let's add another record and see the SQL statements that are generated.
Click the insert button and add a record. (Bill, Stevens).
We can see that by inserting a record, another SQL statement was automatically relayed to our MySQL database. This time it was an "insert into" statement.
Don't worry about the Syntax for now, it's just important to understand that almost every action we perform in PhpMyAdmin sends a set of instructions to our MySQL DB.
Now let's do the same thing we just did, except this time we will manually type out the SQL syntax in the SQL editor. Click the SQL tab on the main menu.
Let's create a SQL statement that selects all the records in our users table and displays them.
To do so just delete the "where" and "1" from the syntax originally displayed in the editor.
Now click "Go".
We can see all the records were retrieved.
Now let's insert a record into our database through the SQL editor.
Type the following line:
INSERT INTO users (id,firstname,lastname,email,date)
First we specify we want to insert data into the users table. Next we specify the columns (id, fname, lname, email and date). Lastly, we specify values to place into each column. The first and last column are intentionally left empty because those are our automatically generated id and date columns.
So as you can see, we can execute SQL commands directly to our MySQL Database using PhpMyAdmin.