Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to select by prefix

Author  Topic 

AlThar
Starting Member

1 Post

Posted - 2010-01-29 : 05:38:10
Hi all.
i got data table with column 'prefix'. This column contains first numbers of phone numbers(like +7926; +7903; +7; +79; etc.)
I got phone number (like +79265713888);
I must select row which prefix matches (the strongest match) phone number`s prefix. In this case i need the row with +7926 prefix. +7 and +79 matches the number too, but i need to select row which prefix is longer. How can i do it fast?
(i write on pgplsql (PostgreSQL))

Thanks a lot...

Kristen
Test

22859 Posts

Posted - 2010-01-29 : 05:40:23
"i write on pgplsql (PostgreSQL)"

Please note that this is a Microsoft SQL Server site, so folk here may not be familiar with your database
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-29 : 07:53:35
Did you try?

where col like 'your_prefix%'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -