postgresql7.1 select p.key, p.value, case when e.config_id = d.default_config_id then 1 else 0 end as default_config_p from portal_element_parameters p, portal_elements e, portal_datasources d where e.datasource_id = d.datasource_id and e.config_id = p.config_id and e.element_id = :element_id