select email_id from dotlrn_member_emails where community_id = :community_id and type = 'on join' insert into dotlrn_member_emails (community_id, type, from_addr, subject, email) values (:community_id, 'on join', :from_addr, :subject, :email) select from_addr, subject, email from dotlrn_member_emails where email_id = :email_id update dotlrn_member_emails set from_addr = :from_addr, subject = :subject, email = :email where email_id = :email_id