Tom Lane wrote:
> Is the name unique? If so you could do
>
> select * from
> (select id from map where name = 'foo'
> union all
> select -1) ss
> limit 1;
>
>
> Another way is a subselect:
>
> select coalesce((select id from map where name = 'foo'), -1);
>
> but this one will actively blow up if there are multiple 'foo' rows,
> so it doesn't solve that problem either.
Can't you just:
select coalesce(id, -1) from map where name = 'foo' ?
Or am I missing something?