PostgreSQL:将 CTE 与 IN 结合使用
PostgreSQL: Using CTE with IN
现在正在学习CTE,下面的查询是超级基础的,它没有任何有用的价值,但我不明白为什么它不起作用
with cte_actors as (
select first_name from actor where first_name like 'P%' or first_name like 'E%'
)
select
first_name
from
actor
where
first_name in (cte_actors)
我得到的错误是“错误:列“cte_actors”不存在”
目前正在使用 postgres 14 和 DBeaver
您需要 SELECT 来自 CTE:
with cte_actors as (
select first_name
from actor
where first_name like 'P%' or first_name like 'E%'
)
select first_name
from actor
where first_name in (select first_name from cte_actors)
现在正在学习CTE,下面的查询是超级基础的,它没有任何有用的价值,但我不明白为什么它不起作用
with cte_actors as (
select first_name from actor where first_name like 'P%' or first_name like 'E%'
)
select
first_name
from
actor
where
first_name in (cte_actors)
我得到的错误是“错误:列“cte_actors”不存在”
目前正在使用 postgres 14 和 DBeaver
您需要 SELECT 来自 CTE:
with cte_actors as (
select first_name
from actor
where first_name like 'P%' or first_name like 'E%'
)
select first_name
from actor
where first_name in (select first_name from cte_actors)