MySQL phpMyAdmin – Run Database Script & SELECT Query

MySQL phpMyAdmin – Run Database Script & SELECT Query


Hello everyone and welcome to a quick how-to
tutorial on using MySQL in phpmyadmin. The purpose of this tutorial is to teach students
who are just learning about SQL in the Computer Science program at Davenport University, how
to run a database script and perform a query in MySQL phpmyadmin. The functions that you will learn in this
tutorial will be how to locate the SQL option on the MySQL database, run a database script,
and write a SELECT query with a FROM clause. By the end of the tutorial, you should know
how to perform a SELECT query without error and run a database script in MySQL. This is a very important tool to use for anyone
in the computer science program, especially for new users who are unfamiliar with SQL
and need a little bit more practice on how to use the database. Alright, let’s get started. So first what we are going to do is we are
going to go to the MySQL phpmyadmin database. So I already have it loaded up in an internet
Firefox browser. So this is the home page, the log-in page
for phpmyadmin MySQL and we’re just going to type in the password. This is going to be my password that IT gave
me. And once you have typed that in we’re going
to select GO and just click on don’t update… Well we’re going to try that one more time. Alright, I must have misspelled my password. Ok, so now we are at the home page of the
phpmyadmin for MySQL database. Over here on the left hand side you will see
the two different databases that everyone should already have. This first top one is going to probably say
your username, this is my personal username so it’s my database. Then the second one that says information_schema,
we’re just going to ignore that one for now; that will be for a later tutorial. So what we’re going to do is we’re going to
click on your username database and you can see that there are no tables found in the
database, which that is ok because we are going to add those tables once we run the
database script. So first what we’re going to do is we’re going
to click on SQL up here in the top tool bar. Alright, and then now we are going to go to
collect the database script. I have it down here in a Word document, and
once this loads it should already by highlighted because I did that previously to the tutorial. I’m going to hit command C or control C, whichever
you have to copy that text. We’re going to minimize that document and
back at the MySQL database we’re going to put our cursor in this text box here and I’m
going to hit command V or paste the database script, and now down here where it says Go,
we’re going to click on Go. Now whenever a green box with a green check
mark pops up, that means that the query that you just ran worked. So, good job everyone, you have just completed
running a database script. So to see that it worked, we’re going to go
back to the left hand side and we’re going to click on the database name, your username
database, and now you see that we have different tables added to our database; the customer,
emp, employee, invoice, line, product, and vendor table. So this is the successful database script
and now what we’re going to do is we’re going to learn how to enter a SELECT query into
SQL. So what we’re going to do from here, next
we are going to go back up to the tool bar where it says structure, SQL, search, and
query, and we’re going to click back on SQL. That’s going to bring us back to this blank
text box and this is where we will write, type out the SQL SELECT query. So what you’re going to do is if you turn
on your caps lock and just type in SE, that’s the first part of SELECT and you can see that
is the first option that pops up. If you just click on SELECT, it has now entered
that in for you. Hit space and now we’re going to add the attributes
from the tables that we want to select. So we’re going to type in P underscore CODE
comma P underscore DESCRIPT comma P underscore PRICE comma P underscore QOH. Now what these mean, this is product code,
product descript, product price, and product quantity on hand. Now if you hit enter, it’s going to create
a brand new line for your SELECT command, for your SQL commands and we are going to
do the FROM clause. So if you just type in FR, that will pop up
FROM and if you click on from, and then for some reason sometimes things get highlighted,
don’t be alarmed, just hit space and we’re going to type in PRODUCT and we’re just going
to click on product. So, this means that we are going to be looking
for the product code, product description, product price and product quantity on hand
information from the product table. Now we’re going to run that query by going
down to the lower right hand corner and we’re going to click on Go. Alright, congratulations, we have now successfully
ran a SELECT query from the product table and you will see that it took about less than
one second for the query to run and we’ve got about sixteen rows total. Now underneath here in the grayish box you
will see your successful query that you just typed out in a different format, but it is
the same thing. Then if you scroll down a little bit you’re
going to see the brand new table that you just created by using the SQL SELECT query
where you got the product code, the product description, the product price, and the product
quantity on hand attributes and all of its data from the product table. So congratulations, you have now successfully
learned how to run a database script in MySQL and performed a SELECT query. Hopefully this tutorial will help students
who are just starting out in the computer science program how to understand how to run
queries and database scripts in MySQL phpmyadmin.