summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorKitzunu <24550914+Kitzunu@users.noreply.github.com>2021-07-25 03:31:03 +0200
committerGitHub <noreply@github.com>2021-07-25 03:31:03 +0200
commit460c138036738ef5bb7821013f52a4f9a47cc0e1 (patch)
treea26ecc95514f306383f715d66c9626a8f8ba699b /docs
parent335d4d6150fd1355e1efcdb5ad36f61e8d731673 (diff)
downloadwiki-460c138036738ef5bb7821013f52a4f9a47cc0e1.tar.gz
wiki-460c138036738ef5bb7821013f52a4f9a47cc0e1.tar.bz2
wiki-460c138036738ef5bb7821013f52a4f9a47cc0e1.zip
chore: Update useful-sql.md
Diffstat (limited to 'docs')
-rw-r--r--docs/useful-sql.md46
1 files changed, 16 insertions, 30 deletions
diff --git a/docs/useful-sql.md b/docs/useful-sql.md
index a15e3c4..78730a5 100644
--- a/docs/useful-sql.md
+++ b/docs/useful-sql.md
@@ -1,31 +1,17 @@
-# useful-sql.md
+---
+tableofcontents: 1
+---
-## Useful SQL snippets:
+# Useful SQL snippets:
-### Table of Contents
- * [Introduction](#introduction)
- * [Loot and Reference Loot Issues](#loot-and-reference-loot-issues)
- + [Find what creatures drop an item directly](#find-what-creatures-drop-an-item-directly)
- + [Find which RLTs an item is in](#find-which-rlts-an-item-is-in)
- + [Find which creatures share a RLT](#find-which-creatures-share-a-rlt)
- + [Find number of items and level statistics for items in a given RLT](#find-number-of-items-and-level-statistics-for-items-in-a-given-rlt)
- + [Recursively find an item by name](#recursively-find-an-item-by-name)
- * [Miscellaneous Issues](#miscellaneous-issues)
- + [Find creature information from a spawn GUID](#find-creature-information-from-a-spawn-guid)
- + [Find all static creatures given a name](#find-all-static-creatures-given-a-name)
- + [Find creatures that use a certain spell](#find-creatures-that-use-a-certain-spell)
- + [Find average wander distance for a creature](#find-average-wander-distance-for-a-creature)
- + [Find other members of a node pool](#find-other-members-of-a-node-pool)
- + [Find respawn timers for a class of object](#find-respawn-timers-for-a-class-of-object)
-
-### Introduction
+## Introduction
These SQL queries are intended to be fast and easy-to-use tools that can help identify and troubleshoot problems in the AzerothCore database. They're here to be a quick reference to help when looking at DB-related problems. If anyone else has any similar useful queries, let me know and I'll add them. Similarly, if you have a common problem for which you'd like a query written, feel free to get in touch.
### Loot and Reference Loot Issues
#### Find what creatures drop an item directly
Note that this doesn't count items dropped from RLTs.
-```SQL
+```sql
SELECT ct.name, clt.chance, ct.maxlevel, it.ItemLevel
FROM `creature_template` ct
JOIN `creature_loot_template` clt ON ct.lootid = clt.entry
@@ -34,7 +20,7 @@ WHERE it.entry = XXXXX;
```
#### Find which RLTs an item is in
-```SQL
+```sql
SELECT rlt.entry, it.entry, it.name
FROM `reference_loot_template` rlt
JOIN `item_template` it ON rlt.Item = it.entry
@@ -43,7 +29,7 @@ WHERE it.entry = XXXXX;
#### Find which creatures share a RLT
Non-recursive.
-```SQL
+```sql
SELECT distinct ct.entry, ct.name
FROM `creature_template` ct
JOIN `creature_loot_template` clt ON ct.lootid = clt.entry
@@ -52,7 +38,7 @@ WHERE clt.Reference = XXXXX;
#### Find number of items and level statistics for items in a given RLT
This is useful when determining which creatures should have a particular RLT in their drop tables.
-```SQL
+```sql
SELECT COUNT(rlt.Item), MIN(it.ItemLevel), MAX(it.ItemLevel), AVG(it.ItemLevel)
FROM `item_template` it
JOIN `reference_loot_template` rlt ON it.entry = rlt.item
@@ -61,7 +47,7 @@ WHERE rlt.entry = XXXXX;
#### Recursively find an item by name
Note this is complex enough that Keira won't run it properly - you will need to run it from a MySQL command prompt. Thanks to @anguaive for this one.
-```SQL
+```sql
SET @ITEM_NAME := 'insert name of item here';
SET @ITEM_ID := (SELECT `entry` FROM `item_template` WHERE `name` = @ITEM_NAME);
@@ -92,7 +78,7 @@ ORDER BY ct.name;
### Miscellaneous Issues
#### Find creature information from a spawn GUID
Bug reports sometimes just reference a GUID with no other information about an NPC. This will find the creature a GUID belongs to.
-```SQL
+```sql
SELECT ct.entry, ct.name, ct.minlevel, ct.maxlevel
FROM `creature_template` ct
JOIN `creature` c ON ct.entry = c.id
@@ -101,7 +87,7 @@ WHERE c.guid = XXXXX;
#### Find all static creatures given a name
You can just use part of the NPC's name (as here, 'Gordunni') and it will find all NPCs with that string in their name.
-```SQL
+```sql
SELECT c.guid, ct.name
FROM `creature` c
JOIN `creature_template` ct ON ct.entry = c.id
@@ -110,7 +96,7 @@ WHERE c.movementtype = 0 AND ct.name LIKE '%gordunni%';
#### Find creatures that use a certain spell
Note this is a bit rough and ready, and only works if the spell is in their first action slot. In this case, XXXX is the spell ID.
-```SQL
+```sql
SELECT ct.entry, ct.name, ct.maxlevel, ss.action_param1
FROM `creature_template` ct
JOIN `smart_scripts` ss ON ct.entry = ss.entryorguid
@@ -119,7 +105,7 @@ WHERE ss.action_param1 = XXXXX;
#### Find average wander distance for a creature
Handy for fixing static creatures.
-```SQL
+```sql
SELECT c.id, AVG(c.wander_distance)
FROM `creature` c
WHERE c.id = XXXX;
@@ -127,14 +113,14 @@ WHERE c.id = XXXX;
#### Find other members of a node pool
Given a node GUID, find if it belongs to a node pool and list the other members.
-```SQL
+```sql
SELECT * FROM `pool_gameobject` WHERE `pool_entry` IN (
SELECT `pool_entry` from `pool_gameobject` WHERE guid = XXXX);
```
#### Find respawn timers for a class of object
Given a object's name, find the respawn timers for all spawns that match that name string.
-```SQL
+```sql
SELECT got.name, go.guid, go.spawntimesecs
FROM `gameobject_template` got
JOIN `gameobject` go ON got.entry = go.id