![](/img/trans.png)
[英]How to select value from a table where value is a dictionary, and the key of the dictionary is a number using SQL query?
[英]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.