Is it possible to insert into IN data obtained from a subquery?

The problem is as follows. I do select with a sheaf from 3 tables and the data at the same time are not unloaded, unloading hangs. But if you make a subquery for one of the tables with a specific indication of the hitch field, then unloading occurs.

Sample upload:

SELECT a.C1 ,a.C2 ,b.C1 ,b.C2 ,b.C3 ,c.C1 FROM table1 a LEFT JOIN table2 b ON a.ID=b.ID LEFT JOIN (SELECT * FROM table3 WHERE ID IN ('123','123n',...) c ON c.ID=a.ID WHERE a.C20 like 'Работает' AND a.C24 IS NULL 

How to make a SQL query?

  • one
    Move the subquery to the CTE. - Akina
  • 3
    I think you should instead of shamanism with rearranging parts of the request from one place to another to look at the request plan and already from this look for how to get away from hangs - Viktorov

0