Adding database function for select.