postgresql7.4 SELECT author_id FROM lr_author WHERE package_id = :package_id INSERT INTO lr_author (author_id, package_id) VALUES (:author_id, :package_id) SELECT DISTINCT group_id FROM lr_author_group WHERE package_id = :package_id SELECT author_id from lr_author WHERE package_id = :package_id LIMIT 1 SELECT distinct u.first_names || ' ' || u.last_name || ' (' || u.email || ')' as name, u.user_id FROM cc_users u WHERE lower(coalesce(u.first_names || ' ', '') || coalesce(u.last_name || ' ', '') || u.email || ' ' || coalesce(u.screen_name, '')) like lower('%'||:value||'%') ORDER BY name SELECT distinct u.first_names || ' ' || u.last_name || ' (' || u.email || ')' as name, u.user_id FROM cc_users u ORDER BY name