select cm.keyword_id, ci.item_id, cr.title, to_char(cr.publish_date, 'Mon FMDD, YYYY') as pretty_publish_date $custom_fields from cr_item_keyword_map cm, cr_revisions cr, cr_items ci, cr_ca_ads ads where cm.item_id = cr.item_id and ci.latest_revision = cr.revision_id and ci.parent_id = :parent_id and ci.content_type = 'ca_ad' and cm.keyword_id = :category_id and -- RBM (2004-01-17) - Dont remember why this was being compared to -- item_id -- ci.item_id = ads.ad_id ci.latest_revision = ads.ad_id order by cm.keyword_id asc, cr.title asc $limit_clause select ci.item_id, cr.title, to_char(cr.publish_date, 'Mon FMDD, YYYY') as pretty_publish_date from cr_revisions cr, cr_items ci where ci.item_id not in (select item_id from cr_item_keyword_map cm $condition_stub) and ci.latest_revision = cr.revision_id and ci.parent_id = :parent_id and ci.content_type = 'ca_ad' order by cr.title asc $limit_clause select * from cr_ca_adsx where revision_id = :revision_id select keyword_id from cr_item_keyword_map where item_id = :ad_id