select count(1) from ($sql_query) as c select cr.content as plain_text from acs_mail_multipart_parts mpp join cr_items ci on mpp.content_item_id=ci.item_id join cr_revisions cr on ci.live_revision=cr.revision_id where multipart_id=:content_item_id and cr.mime_type='text/plain'; select cr.content as html_text from acs_mail_multipart_parts mpp join cr_items ci on mpp.content_item_id=ci.item_id join cr_revisions cr on ci.live_revision=cr.revision_id where multipart_id=:content_item_id and cr.mime_type='text/html';