我已经两次传递参数(:PRODUCT_ID)。我如何通过:PRODUCT_id只有一次用于以下查询
select count(1)
from (
select count(1) album_fa_counter
from actual_configs ac
where ac.config_id = :PRODUCT_ID
and exists (
select 1
from config_participants cp
where CONTRIBUTOR_CATEGORY = 'Featured Artist'
and cp.gpid = ac.gpid
)
) a,
(
select count(1) matching_track_fa_counter
from actual_tracks at1,
actual_configs ac1
where at1.gpid = ac1.gpid
and ac1.config_id = :PRODUCT_ID
and exists (
select 1
from recording_participants rp,
config_participants cp
where cp.CONTRIBUTOR_CATEGORY = 'Featured Artist'
and cp.gpid = at1.gpid
and cp.participant_name = rp.participant_name
and rp.CONTRIBUTOR_CATEGORY = 'Featured Artist'
and rp.isrc = at1.isrc
)
) b
where a.album_fa_counter = 0
or b.matching_track_fa_counter > 0;
答案 0 :(得分:0)
我会尝试解决这个问题:
With
a as
(select count(1) album_fa_counter
from actual_configs ac
where ac.config_id = :PRODUCT_ID
and exists (
select 1
from config_participants cp
where CONTRIBUTOR_CATEGORY = 'Featured Artist'
and cp.gpid = ac.gpid),
b as
(
select count(1) matching_track_fa_counter
from actual_tracks at1,
actual_configs ac1,
a
where at1.gpid = ac1.gpid
and ac1.config_id = ac.config_id
and exists (
select 1
from recording_participants rp,
config_participants cp
where cp.CONTRIBUTOR_CATEGORY = 'Featured Artist'
and cp.gpid = at1.gpid
and cp.participant_name = rp.participant_name
and rp.CONTRIBUTOR_CATEGORY = 'Featured Artist'
and rp.isrc = at1.isrc
)
Select count (1)
from a,b
Where
a.album_fa_counter = 0
or b.matching_track_fa_counter > 0;
现在数据库将a和b视为真实表,因此您在a中使用的参数应被视为表中的正常可用值。 希望这对你有用。
答案 1 :(得分:0)
如果没有对代码进行太多修改,可以通过使用CTE来包含变量,然后在查询中使用它来加入变量:
link = driver.find_element_by_css_selector('a')
driver.execute_script('arguments[0].target="_self";', link)
顺便说一句,我编辑了你的代码而没有重写它,但是做一点努力并用ANSI SQL重写它会好得多。