1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Can someone check this SQL code?

Discussion in 'Mod Creation Help' started by luei333, Dec 13, 2017.

  1. luei333

    luei333 Chieftain

    Joined:
    May 25, 2014
    Messages:
    180
    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!
     
  2. Infixo

    Infixo Warlord

    Joined:
    Jan 9, 2016
    Messages:
    2,286
    Gender:
    Male
    Location:
    Warsaw

Share This Page