Skip to content

Condensing queries.

Benjamin Jackson edited this page Jul 20, 2023 · 4 revisions

When making queries the way I do (creating them for each table for certain combinations) something important to do is condense the queries. You can't have sixty-two different inventory queries for each race/class combination for a template set. The method I use may not be perfect for this use, but it's done a darn good job so far. What I do is select from the tables, summing together racemasks (since Blizz seems to have the most overlap race to race rather than class to class,) grouping by other important columns. For example:

SELECT ID, SUM(RaceMask), ClassMask, AchievementID,                                                                                         Comment FROM mod_ptrtemplate_achievements GROUP BY ClassMask, AchievementID;
SELECT ID, SUM(RaceMask), ClassMask, Button, Action, Type,                                                                                  Comment FROM mod_ptrtemplate_action       GROUP BY ClassMask, Button, Action, Type;
SELECT ID, SUM(RaceMask), ClassMask, BagID, SlotID, ItemID, Quantity, Enchant0, Enchant1, Enchant2, Enchant3, Enchant4, Enchant5, Enchant6, Comment FROM mod_ptrtemplate_inventory    GROUP BY ClassMask, BagID, SlotID, ItemID, Quantity, Enchant0, Enchant1, Enchant2, Enchant3, Enchant4, Enchant5, Enchant6;
SELECT ID, SUM(RaceMask), ClassMask, QuestID,                                                                                               Comment FROM mod_ptrtemplate_quests       GROUP BY ClassMask, QuestID;
SELECT ID, SUM(RaceMask), ClassMask, FactionID, Standing,                                                                                   Comment FROM mod_ptrtemplate_reputations  GROUP BY ClassMask, FactionID, Standing;
SELECT ID, SUM(RaceMask), ClassMask, SkillID, Value, Max,                                                                                   Comment FROM mod_ptrtemplate_skills       GROUP BY ClassMask, SkillID, Value, Max;
SELECT ID, SUM(RaceMask), ClassMask, SpellID,                                                                                               Comment FROM mod_ptrtemplate_spells       GROUP BY ClassMask, SpellID;
Clone this wiki locally