Is it possible to use the WITH clause in the IN clause?

Asked 2 years ago, Updated 2 years ago, 53 views

Is it possible to include the WITH clause in the IN clause as shown in SQL below?

SELECT* FROM customer WHERE id IN(
  WITH_t2AS (SELECT id FROM t2 WHERE id > 1)
  SELECT* FROM t1 WHERE id1 IN (SELECT id FROM_t2)
);

postgresql

2022-09-30 17:56

1 Answers

In the IN section, there is a data output like the select section, so even in the WITH section, the data is
There is no problem as long as it is written so that it can be printed.You can't end it with UPDATE.INSERT, DELETE as well.

For XX IN (...), there is only one item in select.For multiple choices, you can write (XX,YY)IN(...).Therefore, the SELECT* FROM t1 part must be one.

SELECT id1 FROM t1 WHERE id1 IN (SELECT id FROM_t2) would be possible.


2022-09-30 17:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.