You are invited to Log in or Register a free Frihost Account!

learning MySQL

i was wondering if anybody knows of any good books or really good sites that could help the uninformed. thanks
I think there is a section in this forum that lists all good websites that talks about mysql.. Anyway, you can check this sites:

You can choose any of the docs of their home page :
A good integration on php..:

Simple but very useful site :

I think..That's it...
hello! I found good explanation at It really explain on how to use each code for your database using PHP and MySQL

try it and i hope it will also help you in learning MySQL
Books are always better than online tutorials. U should first learn and understand basic RDBMS concepts. Try databases demystfied. It is a great book for basic concepts. I use PHP and Mysql web development (SAMS Publishing) for mysql and php. Beginning Mysql by wrox is also good.
Fire Boar
I could give you a quick runthrough right now. No faffing about. So, here we go.

You've got your database. If you don't, make one. You should use phpmyadmin. I for one am quite experienced in MySQL, yet I have never had to use the CREATE TABLE syntax. I always make the tables in phpmyadmin because it's so much easier. So, make a table with three fields, called test. You're presented with a list of options for each field.

"Field" is the name of the field. It doesn't really matter what you want, but for the purposes of this guide let's have "name", "age" and "address". Next is type. There are loads of options, but the three main ones you'll be using most of the time are "varchar", "int" and "text". Varchar is any combination of characters taking up up to 255 bytes (normally one character is one byte, but for non-standard characters it is often two). Int is a number, and text is a block of text. For this example, make the "name" field a varchar, "age" an int, and make "address" a text field.

Length/Values comes next. That is the maximum length you want the data in each field to be. Set "name" to a maximum length of 30, and "age" to 3 (for age you are probably not going to get anyone older than 999!). Because "address" is a text field, it does not need a length, so leave this box blank.

For now, everything else is unimportant. You will likely be dealing with indexes and primary keys later on, but just ignore it for now. Click "Save".

Alright, so step one complete. You've got your table in the database. Now, you'll need to run some queries on it. Let's start with something to insert data. Click the SQL tab at the top and type the following in:

INSERT INTO test VALUES ('Bob', '27', '6 Frederick\'s Drive')

That very simply adds the values to each field in the table: the first field gets the value "Bob", the second "27" and the third "6 Frederick's Drive". Notice the backslash before the '. It tells MySQL that you do in fact want to put in an apostrophe; you don't want to signal the end of the third bit of data (which is what the apostrophe is used for normally).

Each time you want to add an entry, you would use that type of syntax. Now, suppose you had someone who didn't give their age. You can tell MySQL exactly what you want to insert data into like this:

INSERT INTO test ('name', 'address') VALUES ('Jim', '21 Harvey Way')

This time, instead of blindly adding data to the table 'test', you are telling it where you want each piece of information to go.

Okay, so you've got some data in there. Add some more if you like - it's good to practice. Once you're done, we'll want to start getting data out of the database to be used. Here is the simplest query to do that:


That basically gets everything from each row out of the table "test". The * means everything. If you only wanted to know the age and address of people, and not their name, you would use this instead:

SELECT age, address FROM test

What if you only want to select rows that fulfill certain conditions? In that case, you would use WHERE:

SELECT name FROM test WHERE age='27'

The above would return all the names of people who are exactly 27. Unless you have added in more people, this will only be Bob. Now for one final thing. Insert some more people, just making stuff up. It doesn't really matter what you add, we just need some more entries. Once you're done, we're going to search for the first two people with an age greater than 25. Here is the query:

SELECT * FROM test WHERE age>'25' LIMIT 2

There are two things to note here. First is the ">". That means "greater than". Similarly, "<" means "less than", ">=" means "greater than or equal to". The other thing is LIMIT. I expect you've guessed already, but it just tells MySQL to stop searching once it's found 2 people. LIMIT 3 would stop after the first 3 people, and so on. Pretty straightforward, no?

Right, so we have inserted data and queried it. What next? Let's say that Jim decided to tell us his age after all, and that he is 19 years old. This is what we would do:

UPDATE test SET age='19' WHERE name='Jim'

Three bits here: UPDATE tells MySQL that you want to update it. Following SET are the bits that should be set, and after WHERE we have the conditions (in this case, the person has to be called Jim in order to have his age updated, since it is only Jim that we want to change). If there were two people called, Jim, both of them would have their age set to 19, so be careful. You could narrow it down a little like this:

UPDATE test SET age='19' WHERE name='Jim' AND age='0' LIMIT 1

Here we have AND, which looks for something which fulfills both conditions, but we also have LIMIT 1 cropping up again. This will ensure that only one Jim will be updated, and the Jim in question will not have told us his age previously.

Finally, I'm going to show you how to remove entries. Bob has decided to leave the club, so we will remove him from the table.


I expect you can work out for yourself what that does.

And there you have it. MySQL 101. That is probably all the syntax you're going to need 98% of the time. If you need something else, try looking it up on the mysql webpage. I hope this was helpful.

just google a bit imo..... i use to just copy and paste for my php scripts... now i program in VB.NET with mysql sometimes and i re-write my code rather than copy->paste , so... if that helps any.... probly not but..
thanks alooot for these great links that leads for nice and useful books Smile

i really need it to improve my skills in MySQL Smile
you should definitely learn mysql

u cn learn it using wrox publication books

I learnt it from there

d php and mysql bondin is really gr8

u cn also search for book torrents and ya cn checkout 4 some sample applications at also has programs with php and mysql
Related topics
Where can I find tutorials for MySQL?
Advanced MySQL db merging Tutorials
HELP on PHP MYSQL : everything MESSED UP
PHP, MySQL tutorials
The best way to learn PHP?
SQL vs mySQL
SQL.....Where to start?
knowing php/mysql, Is CGI/Perl worth learning?
whats the best websites for learning mysql?
Trying to Understand MySQL Syntax
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.