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:

CREATE DATABASE,CREATE TABLE,INSERT,SELECT,FROM,WHERE,AND.

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

So you’ve got Mysql installed and if your 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 want put in your
friend’s/girlfriend’s Birthday,favorate 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
with:

( Type in all the commands in bold from here on , 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 )

CREATE DATABASE missjackson
Query OK, 1 row affected (0.00 sec)

then:
USE missjackson
Database changed
Ok so you have created database called missjackson, 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 lets make a table for your missjackson
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 www.mysql.com.Thats 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 dont 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 isnt it? The only problem is you didnt put Brittney’s number in correctly and you forgot to list a column for Birthday’s didnt you? You are in big trouble…
unless you read the next section on how to use the UPDATE, DELETE, and ALTER TABLE command.