Re: Wildcards On Columns?



cyber0ne wrote:
> My use of wildcards thus far has been limited to matching a given
> string anywhere in a column as follows:
>
> SELECT * FROM Table WHERE Column LIKE '%string%'
>
> However, I'm wondering if there's a way to do this in reverse. That
> is, is there a way to match the column anywhere in the string?
> Pseudo-coding it as:
>
> SELECT * FROM Table WHERE 'string' LIKE %Column%
>
> What I'm trying to match is network addresses. Most of the stored
> addresses in this table are exact (i.e. ip-1-2-3-4.location.isp.com)
> but sometimes they encompass an entire group (i.e. location.isp.com).
> When an exact address is given in the code I'm writing, it needs to
> match any rows that contain its exact self or contain a shortened
> version of which it is part.
>
> Any ideas?
>
>
> -cyber0ne
> http://www.cyber0ne.com


SELECT *
FROM Table
WHERE 'string' LIKE '%'+Column+'%' ;

--
David Portas
SQL Server MVP
--

.



Relevant Pages

  • Wildcards On Columns?
    ... My use of wildcards thus far has been limited to matching a given ... is there a way to match the column anywhere in the string? ... match any rows that contain its exact self or contain a shortened ...
    (comp.databases.ms-sqlserver)
  • Re: performance surprise -- why?
    ... On 25 Aug 2004, Anno Siegel wrote: ... >> string to a file and counted the lengths of the lines using a simple ... The substitution method must move parts of the ... > The results show indexing and global matching in the same ballpark, ...
    (comp.lang.perl.misc)
  • Re: performance surprise -- why?
    ... > CCCTAAACCCTAAACCCTAAACCCTAAACCTCTGAATCCTTAATCCCTAAATCCCTAAAT...(30MB string). ... The substitution method must move parts of the ... The results show indexing and global matching in the same ballpark, ... sub substitute { ...
    (comp.lang.perl.misc)
  • Re: WildCard Key
    ... But I have a new need to support filenames based on wildcards. ... I'd use a prefix tree aka trie both ... An empty string matches a terminal vertex ... stars that contains at least one star, ...
    (microsoft.public.vc.stl)
  • Re: Can they be expressed as regular expression?
    ... Base on my current incomplete understanding of your construction method, ... S=abcde be the string. ... A_r would accept any string matching R=bc* but would reject those ... any accepting path of the ...
    (comp.theory)