Created
April 25, 2009 01:04
-
-
Save phillipadsmith/101436 to your computer and use it in GitHub Desktop.
Display the first-level elements of a story given its 'id'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT f.id,ft.name,ft.key_name,f.place,f.object_order | |
FROM story_field f,field_type ft | |
WHERE f.field_type__id = ft.id and ft.active = 't' | |
and f.parent_id = ( | |
select t.id from story_element t,element_type et,at_type at | |
where t.element_type__id=et.id and t.active='t' and et.active='t' | |
and et.type__id=at.id and t.object_instance_id = ( | |
select max(id) from story_instance where story__id = 50706 | |
) | |
and at.top_level='t' | |
) and f.active='t' | |
UNION | |
SELECT t.id,et.name,et.key_name,t.place,t.object_order | |
FROM story_element t,element_type et | |
WHERE t.element_type__id = et.id and et.active = 't' | |
and t.parent_id = ( | |
select t.id from story_element t,element_type et,at_type at | |
where t.element_type__id=et.id and t.active='t' and et.active='t' | |
and et.type__id=at.id and t.object_instance_id = ( | |
select max(id) from story_instance where story__id = 50706 | |
) and at.top_level='t' | |
) and t.active='t' | |
ORDER BY place; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment