All pastes #794683 Raw Edit

Something

public text v1 · immutable
#794683 ·published 2007-11-23 10:34 UTC
rendered paste body
with t (educationeventid, xml_part, iter) as (
       select
               cast(educationeventid as varchar(255)) ,
               substr(substr(xml,641),
                       locate('<educationEventRef id="',
substr(rtrim(xml),641))), 1
       from hubble.educationevent
       where
       locate('<educationEventRef id="', substr(xml,641)) > 0
       union all
       select t.educationeventid,
           rtrim(substr(xml_part,
               locate('<educationEventRef id="', xml_part)+1)),
           iter+1
       from t
       where locate('<educationEventRef id="', xml_part) > 0
         and iter < 20
), tuples (t1, t2) as (
       select educationeventid,
               rtrim(substr(xml_part, locate('"', xml_part)+1,
               locate('"/>', xml_part) - (locate('"', xml_part)+1)))

       from t where iter > 1
)
select e1.educationeventid, e2.educationeventid
from tuples x, hubble.educationevent e1, hubble.educationevent e2
where varchar(x.t1) = e1.educationeventid
 and varchar(x.t2) = e2.educationeventid
 and e1.xml LIKE '%event/1.1%'
 and e2.xml like '%event/1.0%'
;