You are here: Re: [Fwd: Reverse pattern matching] « MsSQL Server « IT news, forums, messages
Re: [Fwd: Reverse pattern matching]

Posted by Hugo Kornelis on 09/30/81 11:16

On Tue, 17 May 2005 17:26:44 -0700, Gary Greenberg wrote:

>I encountered an unusual problem and wonder if anyone had some similar
>experience. I have a table T where the column contains text values with
>wild cards and a query contain exact value. For example
>------------------------
>| A | B |
>------------------------
>|AB% | 1 |
>|X% | 2 |
>|XY% | 3 |
>|% | 4 |
>------------------------
>
>I'd like to make a query "select B from T where A like 'XYZ'"
>I need to get a result sorted by maximum matching. For the liset case it
>should be:
>3
>2
>4
>
>Any help will be greatly appreciated.

Hi Gary,

Try this one:

SELECT B
FROM YourTable
WHERE 'XYZ' LIKE A
ORDER BY LEN(A) DESC

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация