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:
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.Code:Insert into `creature_names` ( `entry`, `name`, `Subname`)
So lets do all of them now:
So, these are all the tables in creature_names and notice how all of them have a `` on them.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`)
Now lets make the same query but put in the values with it:
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.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');
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
the name after Insert into tells what column you want to insert it in.Code:Insert into `items` and e.t.c e.t.c
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:
I think the Query itself explains what its doing.Code:Delete from `creature_names` where `entry` = 123456
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:
Okay this 1 also self explains like any other Query.Code:Update `creature_names` Set `entry` = 654321 where `entry` = 123456
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:
You would have noticed how this time i inserted a ";" at the end of the 1st line.Code:Update `creature_names` Set `entry` = 654321 where `entry` = 123456; Update `creature_names` Set `name` = Panther Where `entry` = 654321
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!!!