daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Sep 26th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE "MyObject" (
  2.   "value" INTEGER NOT NULL,
  3.   "cfg" INTEGER NULL,
  4.   "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  5.   CONSTRAINT "cfg_fk"
  6.     FOREIGN KEY ("cfg")
  7.     REFERENCES "Config" ("id"));
  8.  
  9. CREATE TABLE "Config" (
  10.   "name" TEXT NOT NULL,
  11.   "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT);
  12.  
  13. CREATE TABLE "ConfigKV" (
  14.   "key" TEXT NOT NULL,
  15.   "value" TEXT NOT NULL,
  16.   "cfg" INTEGER NULL,
  17.   "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  18.   CONSTRAINT "cfg_fk"
  19.     FOREIGN KEY ("cfg")
  20.     REFERENCES "Config" ("id"));
  21.    
  22. SELECT * FROM MyObject
  23. INNER JOIN (
  24.   SELECT * from ConfigKV WHERE key == 'foo' AND value == 'bar'
  25. ) as SQ1 on SQ1.cfg == MyObject.cfg
  26. INNER JOIN (
  27.   SELECT * from ConfigKV WHERE key == 'fuz' AND value == 'baz'
  28. ) as SQ2 on SQ2.cfg == MyObject.cfg
  29. WHERE MyObject.value == 42;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top