postgresql7.1
SELECT DISTINCT user_id, username, first_names, last_name, email, pretty_type as user_type
FROM dotfolio_users
WHERE (lower(email) LIKE lower('%' || :q || '%') OR
lower(first_names) LIKE lower('%' || :q || '%') OR
lower(last_name) LIKE lower('%' || :q || '%') OR
lower(username) LIKE lower('%' || :q || '%'))