[英]Append a string value to where in (select distinct field from table)
I would like to append a string value onto an in
clause.我想将 append 字符串值放到
in
子句中。 Eg this query retruns a field of string values:例如,此查询返回一个字符串值字段:
with
lut as (
select *
from mytable
)
select distinct "primary goal" from lut
I can also do this:我也可以这样做:
select distinct "primary goal" from lut union all (select 'trial')
This returns the original data from the first select plus an additional row with value 'trial'.这将返回第一个 select 的原始数据加上一个值为“trial”的附加行。
I want to use this within a where in
clause我想在
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'))
Returns error:返回错误:
ERROR: Query unsupported due to an internal error.
错误:由于内部错误,查询不受支持。 Detail: Unsupported query.
详细信息:不支持的查询。 Where: Oid: 1101.
其中:Oid:1101。
Adding the constant trail directly to the column, wound change nothing for the distinct, so ou would get the wanted result将常量轨迹直接添加到列中,伤口不会改变不同的东西,所以你会得到想要的结果
with
lut as (
select *
from mytable
)
select distinct CONCAT('trial',"primary goal") from lut
IN Clause seems not fully be implemented IN 条款似乎没有完全实施
use JOIN
使用
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.