How to restructure this query:
SELECT * FROM tbl t
WHERE (
t.id IN <subquery1>
OR t.id IN <subquery2>
OR t.id IN <subquery3>
)
... into something that looks more like the following:
SELECT * FROM tbl t
WHERE t.id IN (<subquery1> OR <subquery2> OR <subquery3>)
Note: all 3 subqueries select from the same tbl t, but they select a different column each.
To clarify the subqueries a bit further with some concrete examples:
- subquery1:
SELECT col1 FROM tbl WHERE value=100 - subquery2:
SELECT col2 FROM tbl WHERE value=200 - subquery3:
SELECT col3 FROM tbl WHERE value=300
Table structure:
CREATE TABLE tbl (
id INTEGER PRIMARY KEY,
col1 INTEGER not null,
col2 INTEGER not null,
col3 INTEGER not null,
value INTEGER not null
);