1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    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:
    139
    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 Chieftain

    Joined:
    Jan 9, 2016
    Messages:
    1,360
    Gender:
    Male
    Location:
    Warsaw

Share This Page