473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

Nov 29 '05 #1
3 6368
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
--

Nov 29 '05 #2
> SELECT *
FROM Table
WHERE 'string' LIKE '%'+Column+'%' ;


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

Nov 29 '05 #3
cyber0ne (cy*******@gmail.com) writes:
SELECT *
FROM Table
WHERE 'string' LIKE '%'+Column+'%' ;


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


Then it's time for the standard advice for questions of this type. And that
is that you should always include:

o CREATE TABLE statement for your table (preferrably simplified)
o INSERT statements with sample data.
o The desired result given the sample.

With just a narrative that may not be complete, there is a risk for
misunderstandings. Also, with the information above, it's simple to
post a tested solution.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bharath Dhurjati | last post by:
Hello, I am looking for documentation that specifies the following behavior exhibited by java. The following (assuming MyClass.class is accessible and has a main()) java MyClass * yields...
1
by: Ralph Noble | last post by:
I thought this problem would go away over the Christmas holiday, but of course it did not. I'm trying to write a stored procedure incorporating wildcards, so I can search for variations. Example,...
3
by: sashi | last post by:
Hi, Is it possible to use wildards in SQL to drop a constraint on a table? Thanks!
11
by: Shyguy | last post by:
I need to import a text file pretty much daily. I download the file and change the name to a standard name and then run the code to import the file into a table in my database. The problem is...
10
by: Alvaro Puente | last post by:
Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro
6
by: Andy | last post by:
I have a form with several ComboBoxes. One of these is Surname, can I make it select all the Smiths for example by using wildcards? At the moment my query only picks up the individual Surname...
1
by: Anandan | last post by:
Hi, This is regarding Dataset Filter: WILDCARD CHARACTERS Both the * and % can be used interchangeably for wildcards in a LIKE comparison. If the string in a LIKE clause contains a * or %,...
19
by: Alan Carpenter | last post by:
Access 8 on Win98 and WinXP I'm having trouble with wildcards in the .Filename property of the FileSearch Object giving different results on win98 and XP. I've been successfully using...
5
by: nidaar | last post by:
From a security point of view, is accepting wildcards like "%" in input parameters of stored procedures against any best practices? As an example, if a user defined function uses "Productname...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.