postgresql7.1
select
message_id,
sender_id,
from_addr,
package_id,
sent_date,
body,
subject,
object_id,
log_id
from
acs_mail_log
where [template::list::page_where_clause -name messages]
[template::list::filter_where_clauses -and -name messages]
[template::list::orderby_clause -orderby -name messages]
select distinct ml.log_id, ml.sent_date, ml.sender_id, ml.package_id, ml.subject
from acs_mail_log ml left outer join acs_mail_log_recipient_map mlrm on (ml.log_id=mlrm.log_id)
where ml.log_id is not null
$recipient_where_clause
[template::list::filter_where_clauses -and -name messages]
[template::list::orderby_clause -orderby -name messages]
select file_id from acs_mail_log_attachment_map
where log_id = :log_id