I have two tables as follows:
CREATE List (
id INTEGER,
type INTEGER REFERENCES Types(id),
data TEXT,
PRIMARY_KEY(id, type)
);
CREATE Types (
id INTEGER PRIMARY KEY,
name TEXT
);
Now I want to create a query that determines all ids of List which has given type strings.
For example,
List: 1 0 "Some text" 1 1 "Moar text" 2 0 "Foo" 3 1 "Bar" 3 2 "BarBaz" 4 0 "Baz" 4 1 "FooBar" 4 2 "FooBarBaz" Types: 0 "Key1" 1 "Key2" 2 "Key3"
Given the input “Key1”, “Key2”, the query should return 1, 4.
Given the input “Key2”, “Key3”, the query should return 3, 4.
Given the input “Key2”, the query should return 1, 3, 4.
Thanks!
You have to adjust the having clause to the number of keys you are putting in your where clause. Example for just one key:
SQlFiddle example