I am not very experienced with sql queries and looking for an efficient way to perform the same WHERE IN condition on multiple columns.
More specifically, i'm doing the following:
SELECT a, b FROM links WHERE a IN (90696, 110083, ... 147455) OR b IN (90696, 110083, ... 147455)
Since both IN-lists are identical and can contain several hundreds of items, the above query just doesn't feel very right to me.
If it helps (but I don't think so, actually):
the following condition is always met:
row[x].a < row[x].bfor all rows x in Table links.
Im using MySQL InnoDB. Yet, I'm open to different database solutions if would significantly improve performance.
Currently, the items of the WHERE-IN clause are computed. However, I could also acquire them by an additional query (which would actually be the union of two queries).
The IN-list could be constructed by
SELECT i_id as l FROM t_i WHERE id=x UNION ALL SELECT o_id as l FROM t_o WHERE id=x