select type, type_id from dotlrn_user_types order by type select rel_id from dotlrn_users where user_id= :user_id select type from dotlrn_users, dotlrn_user_types where dotlrn_user_rels.type_id= dotlrn_user_types.type_id and user_id= :user_id > update dotlrn_full_user_rels set portal_id= :portal_id where rel_id = (select rel_id from dotlrn_full_users where user_id= :user_id)