labtech
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_AutoJoinComputersFromContacts
Description
Join Computers into groups
Parameters
Name
Type
Mode
Definition
BEGIN -- AutoJoinComputers Part II: The Rekoning. We join computers to groups based on what contacts are in the group -- join computers into SubGroups using ContactIDs in Computers table INSERT IGNORE INTO SubGroups (SELECT GroupID, c.ComputerID FROM SubGroupsContacts JOIN MasterGroups m USING (GroupID) JOIN Contacts ct USING (ContactID) JOIN Computers c USING (ContactID) WHERE m.ContactJoinOptions & 2 = 2); -- join computers into SubGroups using ContactIDs in ContactComputers table INSERT IGNORE INTO SubGroups (SELECT GroupID, cc.ComputerID FROM SubGroupsContacts JOIN MasterGroups m USING (GroupID) JOIN Contacts ct USING (ContactID) JOIN ContactComputers cc USING (ContactID) WHERE m.ContactJoinOptions & 2 = 2); -- but, Master groups are king, so they will steal-back any computers that belong to them. CALL sp_AutoRemoveComputersMasterTrump(); END