I know this should probably go in the section for SQL but it applys most here and it will help more people here. It is focused more as applys to MySQL and the emulation structure.
But anyways, knowing SQL and how it works is one of the keys to being successful in emulation as well as compiling Ascent or compiling a DLL. Anyways, here we go!
What is SQL?
Dictionary.com defines it as: An industry-standard language for creating, updating and, querying relational database management systems. Thats about it, and it stands for Structured Query Language (SQL).
The SELECT Command
We use the SELECT command to find information we need. So heres the syntax:
Code:
SELECT FROM `tablename` WHERE `columnname` = value;
Heres an example:
Code:
SELECT FROM `creature_names` WHERE `entryid`= 1;
Take note that I'm using `` (Next to 1 on keyboard) to enclose my table and column names. You should use either '' (apostrephes) and sometimes "" (quotations) to outline text. Such as:
SELECT FROM `creature_names` WHERE `name` = 'Example';
For numeral (number) values, do not use any quotations or characteristics to enclose it. See the SELECT example.
The UPDATE Command
This command is used to update exsisting information, meaning, there must already be an entry in the database for the entry your updating, and not a new entry. You don't need the syntax examples from now on just normal examples.
Code:
UPDATE `creature_names` SET `flags1` = 4 WHERE (`entry` = 1);
The DELETE Command
This command is used to delete certain entries. You can use it to delete databases and rows also but I'll just show you entries and rows.
Code:
DELETE FROM `creature_names` WHERE `name` = 'Example';
Code:
DELETE FROM `creature_spawns`;
The AND/OR Command
In the AND command the things being binded by the "AND" both have to hold true for a result to be shown (Have to show both things after WHERE)
Example:
Code:
SELECT FROM `creature_names` WHERE `name` = 'Example' AND `subname` = 'Example';
In the OR command only one of the things has to be true (Have to show one thing after WHERE)
Example:
Code:
SELECT FROM `creature_names` WHERE `name` ='Example' OR `subname` = 'Example';
So in the first example the name AND subname have to be true to show a result. In the second example only the name OR subname has to be true to show a result.
The BETWEEN Command
This command finds all entries between two vaulues.
Example:
Code:
SELECT * FROM `creature_names` WHERE `name` BETWEEN 1 AND 100;
Note the * between SELECT and FROM. Also note that the numeric values don't have marking around them.
You did it! You now know the basic syntax of SQL! Now you can move on the the advanced tutorial (yet to be written).
Thanks and Enjoy!
-SectorSeven