我必须加入表CAMPAIGN
和WF_ACTIVITY
,以便CAMPAIGN.CAMPAIGN_KEY = WF_ACTIVITY.PARAMETERS='CAMPAIGN_KEY='
。WF_ACTIVITY
表的参数列包含值,例如:
CAMPAIGN_KEY=ROAMING_DATA_FLAT
STEP_KEY=START_COLLECTION
PARAM_KEY=BYPASS_PROVISIONING
我只需要从参数列中获取'CAMPAIGN_KEY='
字符串的值,并将其与CAMPAIGN_KEY
表中的CAMPAIGN
列值连接起来。我真的不知道哪些字符串函数可以使用或如何修剪具有值'CAMPAIGN_KEY='
的参数列并对其进行comapre的字符串部分。
答案 0 :(得分:2)
您不需要任何特殊功能来实现您所寻找的目标。
设定:
create table CAMPAIGN (
campaign_id number,
campaign_key varchar(100)
);
create table WF_ACTIVITY (
wf_activity_id number,
parameters varchar(100)
);
insert into CAMPAIGN values (1, 'ROAMING_DATA_FLAT');
insert into CAMPAIGN values (2, 'ROAMING_DATA_ROUND');
insert into WF_ACTIVITY values (1, 'CAMPAIGN_KEY=ROAMING_DATA_FLAT');
insert into WF_ACTIVITY values (2, 'STEP_KEY=START_COLLECTION');
insert into WF_ACTIVITY values (3, 'PARAM_KEY=BYPASS_PROVISIONING');
insert into WF_ACTIVITY values (4, 'CAMPAIGN_KEY=ROAMING_DATA_ROUND');
查询:
select *
from CAMPAIGN c
join WF_ACTIVITY w on 'CAMPAIGN_KEY=' || c.campaign_key = w.parameters
where w.parameters like 'CAMPAIGN_KEY=%';
所有这一切都使用字符串连接来附加" CAMPAIGN_KEY ="在c.campaign_key之前。
结果:
CAMPAIGN_ID CAMPAIGN_KEY WF_ACTIVITY_ID PARAMETERS
----------- ------------ -------------- -----------
1 ROAMING_DATA_FLAT 1 CAMPAIGN_KEY=ROAMING_DATA_FLAT
2 ROAMING_DATA_ROUND 4 CAMPAIGN_KEY=ROAMING_DATA_ROUND
答案 1 :(得分:2)
如another answer中所述,您不需要使用任何字符串函数,但如果您确实想要这样做,则可能需要使用substr
:
SELECT *
FROM CAMPAIGN C
JOIN WF_ACTIVITY WA ON SUBSTR(WA.PARAMETERS,14) = C.CAMPAIGN_KEY
-- the where clause is optional
WHERE SUBSTR(WA.PARAMETERS,0,13) = 'CAMPAIGN_KEY=';