aaiaflat_final
ID Data
1 [2,96,801]
Engine_willie2
ID Data Eng
1 2 3.0
1 96 4.0
1 801 4.6
1 999 5.0
Select
Engine_willie2.ID,
(
CASE
WHEN Engine_willie2.Data = aaiaflat_final.Data
THEN Engine_willie.Data END
)
AS Data,
(
CASE
WHEN Engine_willie2.Data = aaiaflat_final.Data
THEN Engine_willie.Eng END
)
AS Eng
FROM aaiaflat_final
Left Join Engine_willie2 ON
Engine_willie2.ID = aaiaflat_final.ID
WHERE
aaiaflat_final.ID <> ''
我希望查询看起来像这样
ACES_Query
ID Data Eng
1 2 3.0
1 96 4.0
1 801 4.6
我不确定如何解析aaiaflat_final表中的[2,96,801],因为如果Data为2或与Engine_willie2中的data列有任何其他完全匹配的数据,查询将正常运行。
任何帮助将不胜感激。
答案 0 :(得分:0)
加入id
上的表,使用replace()
除去括号,然后find_in_set()
从样本数据中产生所需的结果。
SELECT e.id,
e.data,
e.eng
FROM engine_willie2 e
INNER JOIN aaiaflat_final a
ON a.id = e.id
WHERE find_in_set(e.data, replace(replace(a.data, '[', ''), ']', ''));