About Me

Friday, 13 April 2012

MySQL Syntax

MySQL Syntax

The great thing about everything you do in MySQL is that the "code" is very easy for humans to read, as opposed to harder programming languages like C or C++. Very few special characters and symbols are required to create a MySQL query, and most queries consist entirely of English words!

Strategies to Learn MySQL

The MySQL language is not as complicated as most programming languages, so the best way to learn is with direct examples. Because this tutorial focuses on the combination of MySQL and PHP, most of the examples are ready for you to copy, paste, and run on your web server.

CAPITALIZATION in MySQL Queries

There are many keywords in MySQL, and a good programming habit when using ANY of these words is to capitalize them. This helps draw them out from the rest of the code and makes them much easier to read. Below is an example of a MySQL query written in PHP that retrieves all the data from a MySQL table named "example".
  • $result = mysql_query("SELECT * FROM example")
That line of code is valid PHP, but it also contains valid MySQL. The text that appears between the quotations "SELECT * FROM example", is the MySQL code.
As you probably can tell "SELECT" and "FROM" are the MySQL keywords used in this query. Capitalizing them allows you to tell from a quick glance that this query selects data from a table.
You can view a complete list of MySQL keywords at List of Reserved MySQL Words, but don't worry about memorizing them. You could program relentlessly in MySQL for years without ever using all of the MySQL keywords.

Learn at Your Own Pace

When learning MySQL, it is best to take it one lesson at a time and stop when you feel frustrated. Do not worry if it takes you more than a week to finish this tutorial. If you take the time to progress slowly, you will be much more well-informed about the MySQL database system than if you rushed through it in one sitting.

0 comments:

Post a Comment