好的,我怎么能改变这个:
select * from quallev_qualificationlevel quallev
where quallev.quallev_qual_id in (/* */ select qual.qual_id from qual_qualification qual, qde_qualificationdescription qde
where (qual.qual_id = qde.qde_qual_id)
and qual.qual_startdate <= '2013-12-02'
and qual.qual_enddate >= '2013-12-02'
and qde.qde_namepurpose_cd_id = 7294
and qde.qde_langauge_id = 2
and qde.qde_startdate <= '2013-12-02'
and qde.qde_enddate >= '2013-12-02'
order by qual.qual_id,
qual_code /* */)
and quallev.quallev_startdate <= '2013-12-02'
and quallev.quallev_enddate >= '2013-12-02'
只有一个选择?
我假设我需要使用某种形式的内部联接,只是不确定wt和如何
答案 0 :(得分:1)
替换你的in
条款,你可以做
inner join qual_qualification qual on qual.qual_id = quallev.quallev_qual_id
inner join qde_qualificationdescription qde on qual.qual_id = qde.qde_qual_id
但是inner join
与in
子句不同。
因此,您不应再使用select *
,但至少select quallev.*
如果联接为每个qual_qualification
检索的次数超过1 quallev_qualificationlevel
,您将获得重复的结果,因此您可能需要distinct
子句。