Can someone check this SQL code?

luei333

Warlord
Joined
May 25, 2014
Messages
185
Hello! I'm trying to make a district that effectively replaces 2 districts. The district itself replaces the Campus, and I'm trying to make versions of each Holy Site building that are built in it to have it effectively also replace the Holy Site. I know little about SQL, but I cooked up the following for a couple tables:

Code:
INSERT INTO Buildings (BuildingType, Name, PrereqTech, PrereqCivic, Cost, PrereqDistrict, Description, RequiresRiver, OuterDefenseHitPoints, Housing, Entertainment, EnabledByReligion, PurchaseYield, MustPurchase, Maintenance, TraitType, OuterDefenseStrength, CitizenSlots, RegionalRange, RequiresReligion, InternalOnly, RequiresAdjacentRiver, AdvisorType)
SELECT 'LUEI_' || BuildingType || '_WAKANDA', Name, PrereqTech, PrereqCivic, Cost, 'DISTRICT_LUEI_NECROPOLIS', Description, RequiresRiver, OuterDefenseHitPoints, Housing, Entertainment, EnabledByReligion, PurchaseYield, MustPurchase, Maintenance, 'TRAIT_CIVILIZATION_DISTRICT_LUEI_NECROPOLIS', OuterDefenseStrength, CitizenSlots, RegionalRange, RequiresReligion, InternalOnly, RequiresAdjacentRiver, AdvisorType
FROM Buildings
WHERE Buildings.PrereqDistrict IS 'DISTRICT_HOLY_SITE' AND Buildings.IsWonder IS false AND TraitType IS NULL;

INSERT INTO BuildingReplaces (CivUniqueBuildingType, ReplacesBuildingType)
SELECT  'LUEI_' || BuildingType || '_WAKANDA', BuildingType
FROM Buildings
WHERE Buildings.PrereqDistrict IS 'DISTRICT_HOLY_SITE' AND Buildings.IsWonder IS false AND TraitType IS NULL;

INSERT INTO BuildingPrereqs (Building, PrereqBuilding)
SELECT  'LUEI_' || BuildingType || '_WAKANDA', PrereqBuilding
FROM Buildings
INNER JOIN BuildingPrereqs
ON Buildings.BuildingType = BuildingPrereqs.Building
WHERE Buildings.PrereqDistrict IS 'DISTRICT_HOLY_SITE' AND Buildings.IsWonder IS false AND TraitType IS NULL;

So, first off, I only want the non-unique, non-wonder Holy Site buildings to be copied for my trait here, so I'm wondering if the WHERE clause is structured correctly. One of my concerns is that the IsWonder will appear not as false, but as NULL or 0 or something.

Second, the BuildingPrereqs INSERT, I'm trying to keep the same BuildingType selected throughout all of my tables for obvious reasons, but I need the data from other tables, like PrereqDistrict and a bunch of other tables' data. I'm pretty green as far as SQL goes, so I don't know if the INNER JOIN is required, or if I can do it in the Civ 6 database, or whatever. If this is not the way to do it, please point me in the right direction.

Once I have good code for these tables/issues, I should be able to extend it to the rest of it pretty easy. Thanks in advance!
 
Back
Top Bottom