postgresql7.2
SELECT
r.title as resource_title,
r.description as resource_description,
r.revision_id as resource_revision_id
FROM rl_resources_revisionsx r, cr_items i, rl_resources rs
WHERE r.resource_revision_id = i.live_revision and
r.item_id = rs.resource_item_id and
rs.approved_p = 't'
ORDER BY r.title
SELECT
c2.short_name,
r.title as resource_title,
substring(r.description,1,200) || '...' as resource_description,
r.revision_id as resource_revision_id,
r.item_id as resource_item_id
FROM
rl_resources_revisionsx r,
rl_resources rl,
cr_items i,
rl_resource_category_map m,
rl_resource_category_map m2,
rl_resource_category c,
rl_resource_category c2
WHERE
r.resource_revision_id = i.live_revision and
m.resource_item_id = r.item_id and
m2.resource_item_id = r.item_id and
m.category_id = :category and
m.category_id = c.category_id and
m2.category_id = c2.category_id and
c.category_type != c2.category_type and
r.item_id = rl.resource_item_id and
rl.approved_p = 't'
ORDER BY c2.short_name, r.title
SELECT
count(*)
FROM rl_resources_revisionsx r, cr_items i, rl_resources rl
WHERE r.resource_revision_id = i.live_revision
and r.item_id = rl.resource_item_id and
rl.approved_p = 't'
SELECT
count(*)
FROM rl_resources_revisionsx r, cr_items i, rl_resources rl
WHERE r.resource_revision_id = i.live_revision
and r.item_id = rl.resource_item_id and
rl.approved_p = 'f'
SELECT
t.short_name as type_name,
t.description as type_desc,
c.short_name as cat_name,
c.description as cat_desc,
c.category_id
FROM
rl_resource_category_type t,
rl_resource_category c
WHERE
c.category_type = t.category_id
ORDER BY t.ordering, c.short_name
SELECT
t.short_name as type_name,
c.short_name as cat_name
FROM
rl_resource_category_type t,
rl_resource_category c
WHERE
c.category_type = t.category_id
and c.category_id = :category