| | Emulator Server Guides Guides for working with World of Warcraft Emulator servers. Learn how to create a WoW Server here.
[NO QUESTIONS HERE] |  | 
06-30-2009
| | Private | | | Join Date: Mar 2009
Posts: 12
Reputation: 13 | | Working with SQL Querys and How to Make them! Hey All!!
Im making a Shot Guide which teaches you how to make some easy SQL Queries.
there are 4 Most Common Commands for everyone to remember:
Insert:
Delete:
Update:
Select:
Alright, Lets work with the Insert Query Now.
Lets Suppose you want to Add an Npc in creature_names with entry Id 123456
and add more stuff to it e.t.c, e.t.c...
Now we will type the Query in the "Query" Box or you can also type it in notepad. I recommend using Notepad atm for better understanding...
Alright so here is the Query i typed till now: Code: Insert into `creature_names` ( `entry`, `name`, `Subname`)
The above query only commands the Database to add fields into the Column Creature_names, but this Query will fail if you execute it cause its Half and it has no values. We will want to type in all the columns creature_names have with a comma and a space between them all.
So lets do all of them now: Code: insert into `creature_names` (`entry`, `name`, `subname`, `info_str`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`)
So, these are all the tables in creature_names and notice how all of them have a `` on them.
Now lets make the same query but put in the values with it: Code: insert into `creature_names` (`entry`, `name`, `subname`, `info_str`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`)
values ('123456', "Tigerresse", "", '', '0', '7', '0', '0', '0', '0', '14330', '0', '0', '0', '1', '1', '0', '0');
You should have understood which value is for which field. We started with entry then name, then Subname and in the Values the 1st number 123456 tells us that its for entry Id, for Name its Tigerresse and you would have noticed that "" is also there for Subname. It actually means the field is Blank.
This is How you can work with every table and every column in the database. For example Items, for that you ll have to start with Code: Insert into `items` and e.t.c e.t.c
the name after Insert into tells what column you want to insert it in. Now the Second Command is Delete:
Okay, this is like the easiest Query ever!!!
Now for example you want to delete some record from the database.
Well 1st you need to know what column it is and what Entry Id is that record saved with.
Lets Suppose we want to delete the Tigerresse we made above.
So we will use the following: Code: Delete from `creature_names` where `entry` = 123456
I think the Query itself explains what its doing.
Its deleting a Record which starts with the Entry Id 123456 and its deleting from the table creature_names. Update:
This Query is for updating some Old Record saved in the database.
For example if we want to Update the Entry Id of the Tigerresse we made above.
So we will use the following query: Code: Update `creature_names` Set `entry` = 654321 where `entry` = 123456
Okay this 1 also self explains like any other Query.
Its telling the DB to Update the field with Entry ID 654321 whose entry Id is 123456 in the Creature_names Column.
Now if we want to Update the name too, we would use the following Query: Code: Update `creature_names` Set `entry` = 654321 where `entry` = 123456;
Update `creature_names` Set `name` = Panther Where `entry` = 654321
You would have noticed how this time i inserted a ";" at the end of the 1st line.
It shows how there is a Line break and how the Sql Query is continuing.
Now the 4th Query Select is what i will teach you later, as I gtg atm. But if you learned above 3, you would be able to make up your own Query and work with it.
Anyways!
Thanks For Reading!!!
Last edited by Abdullaah; 06-30-2009 at 08:00 AM.
Reason: oO!
| Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx. 
06-30-2009
|  | Master Sergeant | | | Join Date: Jul 2008 Location: Squire-DB Admin
Posts: 86
Reputation: 26 Level up: 74%, 131 Points needed |   | | | Bump! This is good | 
07-02-2009
|  | Knight-Captain | | | Join Date: Feb 2008
Posts: 428
Reputation: 43 Level up: 42%, 409 Points needed |  | | | Looks like effort was put into it. | 
07-05-2009
| | Private | | | Join Date: Mar 2009
Posts: 12
Reputation: 13 | | Thanks!!
Bump! | 
07-26-2009
| | New User | | | Join Date: Sep 2007
Posts: 10
Reputation: 1 | | | Thx :P I think most people need to read this^^ | 
08-08-2009
| | Private | | | Join Date: Mar 2009
Posts: 12
Reputation: 13 | | Quote:
Originally Posted by daniel3896 Thx :P I think most people need to read this^^ |
hahaha yeah:P |  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -4. The time now is 03:36 AM. |