I really hate SQL

This commit is contained in:
2016-04-22 20:00:31 +10:00
parent ba295099f3
commit 5285397101
2 changed files with 11 additions and 3 deletions
+10 -2
View File
@@ -32,6 +32,14 @@ INSERT OR IGNORE INTO InventoryItems (name, type, durability) VALUES
("potion", "consumable", 100)
;
--DEBUG: Test cases
INSERT INTO LiveCharacters
--DEBUG: this is supposed to archive the dead characters
INSERT INTO DeadCharacters (uid, owner, handle, avatar, birth) SELECT uid, owner, handle, avatar, birth FROM LiveCharacters;
DELETE FROM LiveCharacters WHERE uid IN (SELECT uid FROM DeadCharacters);
--Insert into DeadCharacters From LiveCharacters all characters who's HP has reached zero or below
INSERT INTO DeadCharacters (uid, owner, handle, avatar, birth)
SELECT uid, owner, handle, avatar, birth FROM LiveCharacters WHERE
SELECT character FROM CharacterStatistics WHERE
SELECT uid FROM CombatStatistics WHERE health <= 0;
DELETE FROM LiveCharacters WHERE uid IN (SELECT uid FROM DeadCharacters);
+1 -1
View File
@@ -50,7 +50,7 @@ CREATE TABLE IF NOT EXISTS LiveCharacters (
--metadata
owner INTEGER REFERENCES UserAccounts(uid),
handle varchar(100) UNIQUE,
handle varchar(100),
avatar varchar(100),
birth timestamp NOT NULL DEFAULT (datetime()),