Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Wildcards On Columns?
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


Report this thread to moderator Post Follow-up to this message
Old Post
cyber0ne
11-29-05 04:23 PM


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
--


Report this thread to moderator Post Follow-up to this message
Old Post
David Portas
11-29-05 04:23 PM


Re: Wildcards On Columns?
> SELECT *
>  FROM Table
>  WHERE 'string' LIKE '%'+Column+'%' ;

That's returning all rows, regardless of the string.


Report this thread to moderator Post Follow-up to this message
Old Post
cyber0ne
11-29-05 04:23 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 11:16 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006