|
Home > Archive > Microsoft SQL Server forum > November 2005 > Wildcards On Columns?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Wildcards On Columns?
|
|
| cyber0ne 2005-11-29, 11:23 am |
| 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
| |
| David Portas 2005-11-29, 11:23 am |
| 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
--
| |
| cyber0ne 2005-11-29, 11:23 am |
| > SELECT *
> FROM Table
> WHERE 'string' LIKE '%'+Column+'%' ;
That's returning all rows, regardless of the string.
|
|
|
|
|