PDA

View Full Version : Join on first match?


psychlopes
Jan 8, 2009, 12:25 AM
Hello all,

Can someone tell me How I can join a table (A) on a table (B) on a sorted column using a join condition so that only the first match is selected as the joined record?

For instance, I have:

Table A

Phone numbers
983357654

Table B
Prefixes

9833
983
98
9

I want to joib table A and B using the condition that the phone number is "LIKE" the prefix% . But I want only the first match , i.e. in this example 9833

Any ideas?

arun1028
Jun 10, 2009, 01:37 AM
u can use as
CREATE view anname
as
select firstcolomname,secondcolomname,
from firsttablename JOIN secondtablename
on firsttablename.UserID=secondtablename.UserID