Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- species.id
- FROM
- encyclopedia.species
- JOIN
- encyclopedia.common_names ON (common_names.owner_id = species.id AND common_names.owner_type = 'Species')
- WHERE
- species.name ILIKE E'%gavia%' OR common_names.name ILIKE E'%gavia%'
- GROUP BY
- species.id
- ORDER BY
- COALESCE(common_names.name, species.name);
Add Comment
Please, Sign In to add comment