Skip to content

Instantly share code, notes, and snippets.

@ysr23
Last active November 16, 2016 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysr23/586d6b4440b5e2da98456638c57933f7 to your computer and use it in GitHub Desktop.
Save ysr23/586d6b4440b5e2da98456638c57933f7 to your computer and use it in GitHub Desktop.
SELECT t1.child_pid as Lev0
, e1.type as Lev0Type
, t1.parent_pid AS lev1
, tt2.value AS lev1_Name
, e2.type as Lev1Type
, t2.parent_pid as lev2
, tt3.value AS lev2_Name
, e3.type as Lev2Type
, t3.parent_pid as lev3
, tt4.value AS lev3_Name
, e4.type as Lev3Type
, t4.parent_pid as lev4
, tt5.value AS lev4_Name
, e5.type as Lev4Type
, t5.parent_pid as lev5
, tt6.value AS lev5_Name
, e6.type as Lev5Type
, t6.parent_pid as lev6
, tt7.value AS lev6_Name
, e7.type as Lev6Type
, t8.parent_pid as lev7
, tt7.value AS lev7_Name
, e8.type as Lev7Type
FROM
pip_pip AS t1
LEFT JOIN
pip_pip AS t2 ON t2.child_pid = t1.parent_pid
LEFT JOIN
pip_pip AS t3 ON t3.child_pid = t2.parent_pid
LEFT JOIN
pip_pip AS t4 ON t4.child_pid = t3.parent_pid
LEFT JOIN
pip_pip AS t5 ON t5.child_pid = t4.parent_pid
LEFT JOIN
pip_pip AS t6 ON t6.child_pid = t5.parent_pid
LEFT JOIN
pip_pip AS t7 ON t7.child_pid = t6.parent_pid
LEFT JOIN
pip_pip AS t8 ON t8.child_pid = t7.parent_pid
LEFT JOIN
entity e1 ON t1.child_pid = e1.pid
LEFT JOIN
entity e2 ON t1.parent_pid = e2.pid
LEFT JOIN
title tt2 on tt2.entity_pid = e2.pid
LEFT JOIN
entity e3 ON t2.parent_pid = e3.pid
LEFT JOIN
title tt3 on tt3.entity_pid = e3.pid
LEFT JOIN
entity e4 ON t3.parent_pid = e4.pid
LEFT JOIN
title tt4 on tt4.entity_pid = e4.pid
LEFT JOIN
entity e5 ON t4.parent_pid = e5.pid
LEFT JOIN
title tt5 on tt5.entity_pid = e5.pid
LEFT JOIN
entity e6 ON t5.parent_pid = e6.pid
LEFT JOIN
title tt6 on tt6.entity_pid = e6.pid
LEFT JOIN
entity e7 ON t6.parent_pid = e7.pid
LEFT JOIN
title tt7 on tt7.entity_pid = e7.pid
LEFT JOIN
entity e8 ON t7.parent_pid = e8.pid
WHERE
t1.child_pid IN (SELECT
pid
FROM
version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment