繁体   English   中英

Append 一个字符串值到哪里(从表中选择不同的字段)

[英]Append a string value to where in (select distinct field from table)

我想将 append 字符串值放到in子句中。 例如,此查询返回一个字符串值字段:

with

lut as (
select *
from mytable
)

select distinct "primary goal" from lut

我也可以这样做:

select distinct "primary goal" from lut union all (select 'trial')

这将返回第一个 select 的原始数据加上一个值为“trial”的附加行。

我想在where in子句中使用它

with

lut as (
select *
from mytable
)

select *
from anothertable
where event_name in (select distinct "primary goal" from lut union all (select 'trial'))

返回错误:

错误:由于内部错误,查询不受支持。 详细信息:不支持的查询。 其中:Oid:1101。

将常量轨迹直接添加到列中,伤口不会改变不同的东西,所以你会得到想要的结果

with

lut as (
select *
from mytable
)

select distinct CONCAT('trial',"primary goal") from lut

IN 条款似乎没有完全实施

使用JOIN

with

lut as (
select *
from mytable
)

select *
from anothertable a JOIN (select distinct "primary goal" as lut_name from lut union all (select 'trial')) t1
ON a.event_name = t1.lut_name

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM