New to Mysql? Read the Series and Become an Expert

This is the beginning of a series where I will work through the basic Mysql commands that you will need to manage a database. These commands are covered in this part of the series:


Series name: MissJackson part I, starting out
Skill level: Newbie

So you’ve got Mysql installed and if you are like me you can’t wait to enter all your old baseball cards in your new database so you can sell them on eBay, or maybe you won’t put in your
friend’s/girlfriend’s Birthday, favorite music, address, phone number, favorite music artist…( you don’t ever want to forget your girlfriend’s birthday as you may already know…). Anyway
so you got all this important crap, how do you cram it into Mysql? Ok, first you will have to get into MySQL. Once you are in Mysql you’ve got to create a database so you have something to work

( Type in all the commands in bold from here on, the output will be listed here in italics )

( all commands must be ended with a semi-colon  ‘;’ except for a few, like the CREATE DATABASE command and the USE command )

Query OK, 1 row affected (0.00 sec)

USE miss Jackson
Database changed
Ok, so you have created a database called miss Jackson and set it as the current database with the USE command. (If Mysql says permission denied, read the article on the GRANT command, you might not have the privileges needed). Next, you will have to create the tables that you can put your data in.
A simple example of a table in real life is like the table of contents in a book. you have:

Chapter: Page number:
Beginning Mysql………………1
Basic Mysql commands…………24
Mysql data types…………….37

If you were to make a Mysql table similar to the table of contents listed here you would make a column called “Chapter” and one called
“Page number” right? The chapter names and page numbers would simply be entries in your table. Ok let’s make a table for your miss Jackson
database, well call the table “girlfriends” and in this table, you can put info about all 3 of your girlfriends (lucky bastard…)

Query OK, 0 row affected (0.00 sec)
(You can enter Mysql commands that span several lines and whitespace)
Alright! Now you’ve got a table that you can insert data into. To insert your girlfriends’ info enter the following:

Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

Ok, see how that worked? You put the data into your table exactly how the columns are set up, so they line up perfectly. This is only one way to use the INSERT command and you can find the full
documentation at great and all you say, I put it in but how do I get it out? That brings us to another important Mysql command, SELECT.

|firstname | lastname | phonenumber |
| Brittney | Spear   |     7838292 |
| Christina| Aguil|     7352938 |
| Pamela   | Ander |     7834829 |
3 rows in set (0.00 sec)

Ok there you go, you can see all of your girlfriends right there, in your very own table. What if you don’t want to get all that info
about Pamela and Christina when all you want to see is Brittney’s info?

|firstname | lastname | phonenumber |
| Brittney | Spear  |     7838292 |
1 row in set (0.00 sec)

As you can see SELECT *, selects all entries or you can get info by telling MySQL just what columns you want to see. First, you must tell Mysql what data you want to get (firstname,lastname…)
then you tell Mysql what table you want to get it from, FROM girlfriends, next you tell MySQL what entry you want to get the data from WHERE firstname=”Brittney”. Almost too easy isn’t it? The only problem is you didn’t put Brittney’s number incorrectly and you forgot to list a column for Birthday’s didn’t you? You are in big trouble…
unless you read the next section on how to use the UPDATE, DELETE, and ALTER TABLE command.