Re: Weird join...

From: "Mischa Sandberg" <mischa_sandberg(at)telus(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Weird join...
Date: 2004-07-12 17:43:17
Message-ID: V4AIc.25685$Rf.15828@edtnps84
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Assuming:
table Phone(Number varchar(11))
table Country(Prefix varchar(11), Name varchar(99), ...)

select *
from Phone, Country
where Prefix = (select max(Prefix) from Country where Number like
Prefix+'%')

""Costin Manda"" <costin(at)interpoint(dot)ro> wrote in message
news:00a401c467f5$464b3980$96b0e6c1(at)Costin(dot)(dot)(dot)
> I need to join two tables in postgres (or any other SQL) like this:
> table 1 has a list of phone numbers
> table 2 has a list of country prefixes (like 40 for romania 407 for
romania
> mobile, etc)
>
> I want to join the tables so that a number like
> 407111111 in table 1
> is joined ONLY with
> 407 in table 2

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Loftis, Charles E 2004-07-12 17:50:39 Re: using 'count' to show number of dupes
Previous Message Stephan Szabo 2004-07-12 17:39:00 Re: using 'count' to show number of dupes