MySQL Introductions


First, let's make an introduction to this introductory tutorial. SQL (sometimes pronounced as "Sequel") is a database management system that pretty much overran Access databases over the past few years because it is more secure, easier to maintain, easier to function, and is faster overall.

Ok, now then. This tutorial is a MySQL tutorial, not SQL, so don't expect for me to teach all of the terminal commands...So basically, this is just a query tutorial. A query, for those of you who really are just starting, is a batch of commands, or a group of commands.

Ok, this tut isn't going to mean jack if you don't have a webserver with SQL installed, so if you do, make a database. Any database, I don't care what the name is, it's irrelevent to me. I made one named "tut", even though you won't see me mention anything about changing the database itself, so as I said...it's irrelevant.

The bread and butter of SQL is creating tables. SQL is the easiest part of development, so just read closely and you shouldn't have to go through this tut again. To create a table, you will only need two or more commands. Here is an example of a CREATE command:
Code:
CREATE TABLE  tutorial (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name TEXT
);
Ok, don't start ranting that you are confused just yet, I will try and take care of it. Ok, obviously the command to create a table is CREATE TABLE. Easy to remember, it's in the book read it sometime. Ok, tutorial is the name I gave the table, the name DOESN'T HAVE TO BE IN CAPS!. Now, in PHP your brackets might be {} or [], but this is SQL, and we like parenthasis So if you noticed, all of our row commands are in ();. Ok, now the weird looking part, our rows. The first thing to making a row, is put the name you want. I always make my first row on a table id so that I can sort through it easily. Now, the stuff next to it: INT means that only integers or numbers are going to be in this row. NOT NULL means it can't be left blank (NULL means it can!), AUTO_INCREMENT means that each entry the id will increase by one. It's pretty handy PRIMAY KEY is pretty self explanitory. If you look after my name row, I have TEXT, this says that there is going to be text in there.

Next lesson, inserting data into our newly created table.
Code:
INSERT INTO tutorial SET
name = "New Skin";
Surely I shouldn't need to explain much for that one. It's row name = "what you want put in", <- and a comma! Unless it was the last or only row you are changing, then you need a semicolon [;].

Ok, that was simple enough...NEXT!!! This is one of the more difficult "basic" commands, because it is actually searching your database and you have to know what you are looking for, and that is updating the table.
Code:
UPDATE tutorial SET name="<a href=\"http://www.visualdesigncore.com\">Yes</a>" WHERE id=1;
All I did there was change the name row and put an HTML link to VD-Core in. This only changed the row that id is 1. If you are wondering why I have the \ in there, whenever you use a " in SQL for an HTML command or whatnot, you need to put a \ in front of it. Otherwise, it doesn't work too good.

Now you see why I use an id row By the way, I'm not going to explain in as much detail as I did when I showed how to create a table, beings that was the easy part. If anyone has any questions, DO NOT HESITATE TO POST THEM IN HERE! I'm going to close this tutorial from here, as I said..if you have any questions regarding this tutorial to post them, and if you want to know any basic commands that I failed to mention, ask. Don't ask me how to integrate PHP and MySQL just yet, that's the next tutorial...but anything MySQL, yesh...ask here

Quick Tutorial Search