From: | David McNett <nugget(at)macnugget(dot)org> |
---|---|
To: | Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: ranked subqueries vs distinct question |
Date: | 2008-05-14 14:28:50 |
Message-ID: | 5292F47A-F488-4169-899F-35844C588489@macnugget.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On May 14, 2008, at 9:07 AM, Karsten Hilbert wrote:
> That doesn't work, unfortunately, because the urb (cities)
> table doesn't have the zip code. That's stored in a street
> table which foreign keys into the urb table. The
> dem.v_zip2data view aggregates streets, cities, states and
> countries for which there is a know linkage to a zip code at
> the street level. IOW, there are cities for which there is
> no known zip code. I want those to be matched, too, of
> course, courtesy of the user typing part of their name.
I think perhaps you have misunderstood what I was suggesting. If the
SQL in your original post works, then my suggestion will also work.
In my haste to reply I accidentally omitted the where clause of the
query.
Wouldn't this (full example) work?
SELECT
name,zip,
(SELECT zip = '04317') as zipmatch
FROM
dem.urb
WHERE name ilike 'lei%'
ORDER BY zipmatch DESC, name;
If your code runs, this will too.
From | Date | Subject | |
---|---|---|---|
Next Message | Decibel! | 2008-05-14 14:35:10 | Re: ranked subqueries vs distinct question |
Previous Message | Karsten Hilbert | 2008-05-14 14:07:00 | Re: ranked subqueries vs distinct question |