Question

Ok so how can I change this:

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'

to only have one select ?

I assume I need to use some form of Inner join, just not sure wt and how

Was it helpful?

Solution

to replace your in clause, you could do

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

But an inner join is not the same as an in clause. So you should not anymore use select *, but at least select quallev.*

And if the join retrieve more than 1 qual_qualification for each quallev_qualificationlevel, you will get duplicate results, so you may need a distinct clause.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top