By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Table.Select not work with '*' in middle of query...

P: n/a
VM
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll
throw an exception. How can I search for any rows that begin with '<del>'
and end with 'BOX'?
Would it also be possible to retrieve any rows that begin with '*<del>' and
end with 'BOX*' (ie. "col_output like '*<del>*BOX*' " ) ?

Thanks.


Nov 16 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

"VM" <vo******@yahoo.com> wrote in message
news:eV*************@TK2MSFTNGP12.phx.gbl...
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll
throw an exception. How can I search for any rows that begin with '<del>'
and end with 'BOX'?
Would it also be possible to retrieve any rows that begin with '*<del>' and end with 'BOX*' (ie. "col_output like '*<del>*BOX*' " ) ?

Thanks.

I'm not entirely sure, but you might try using the percent symbol (%) in
place of the asterisks (*).

"col_output like '<del> %BOX' "
Rick Sawtell
Nov 16 '05 #2

P: n/a
VM
I tried that but it doesn't work either.

VM

"Rick Sawtell" <r_*******@hotmail.com> wrote in message
news:up*************@TK2MSFTNGP12.phx.gbl...

"VM" <vo******@yahoo.com> wrote in message
news:eV*************@TK2MSFTNGP12.phx.gbl...
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll
throw an exception. How can I search for any rows that begin with '<del>' and end with 'BOX'?
Would it also be possible to retrieve any rows that begin with '*<del>'

and
end with 'BOX*' (ie. "col_output like '*<del>*BOX*' " ) ?

Thanks.

I'm not entirely sure, but you might try using the percent symbol (%) in
place of the asterisks (*).

"col_output like '<del> %BOX' "
Rick Sawtell

Nov 16 '05 #3

P: n/a
VM <vo******@yahoo.com> wrote:
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll
throw an exception. How can I search for any rows that begin with '<del>'
and end with 'BOX'?


Have you tried:

col_output like '<del>*' AND col_output like '*BOX'

?

The reason your previous attempt didn't work is that, as the docs
state:

<quote>
Wildcards are not allowed in the middle of a string. For example,
'te*xt' is not allowed.
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

P: n/a
VM
It wouldn't work because then it'd return this string:
<del> BELLEVUE STREET \r\n
<czz> BOXVILLE MA 10029-2293

The query must only return something like this:
<del> PO BOX 19930 \r\n
<czz> HOUSTON TX 10029-2293

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
VM <vo******@yahoo.com> wrote:
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll
throw an exception. How can I search for any rows that begin with '<del>' and end with 'BOX'?


Have you tried:

col_output like '<del>*' AND col_output like '*BOX'

?

The reason your previous attempt didn't work is that, as the docs
state:

<quote>
Wildcards are not allowed in the middle of a string. For example,
'te*xt' is not allowed.
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #5

P: n/a
VM <vo******@yahoo.com> wrote:
It wouldn't work because then it'd return this string:
<del> BELLEVUE STREET \r\n
<czz> BOXVILLE MA 10029-2293

The query must only return something like this:
<del> PO BOX 19930 \r\n
<czz> HOUSTON TX 10029-2293


Well the first would match '<del> *BOX' if you could do that anyway, as
the * would match "BELLEVUE STREET \r\n<czz> " wouldn't it?

What do you *really* want it to do?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

P: n/a
VM
In my table, I have two records and in col_output, the 2 string values are:

<del> BELLEVUE STREET
<csz> BOXVILLE MA 10029-2293
---and---

<del> PO BOX 19930 \r\n
<czz> HOUSTON TX 10029-2293

I want to retrieve the second record with only the string 'BOX' available
create the query. But you're right because '<del> * BOX*' would also bring
the first one.

I know there's a better way to store the data but for now the client wants
it like this.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
VM <vo******@yahoo.com> wrote:
It wouldn't work because then it'd return this string:
<del> BELLEVUE STREET \r\n
<czz> BOXVILLE MA 10029-2293

The query must only return something like this:
<del> PO BOX 19930 \r\n
<czz> HOUSTON TX 10029-2293


Well the first would match '<del> *BOX' if you could do that anyway, as
the * would match "BELLEVUE STREET \r\n<czz> " wouldn't it?

What do you *really* want it to do?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #7

P: n/a
VM <vo******@yahoo.com> wrote:
In my table, I have two records and in col_output, the 2 string values are:

<del> BELLEVUE STREET
<csz> BOXVILLE MA 10029-2293
---and---

<del> PO BOX 19930 \r\n
<czz> HOUSTON TX 10029-2293

I want to retrieve the second record with only the string 'BOX' available
create the query. But you're right because '<del> * BOX*' would also bring
the first one.


So what is it that makes the second different from the first for you?
Is it that BOX is on its own? Do you actually want <del> * BOX *? If
so, just do

foo LIKE '<del > * ' and foo LIKE '* BOX *'

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #8

P: n/a


If " col_output like '<del> *BOX' " is part a SQL string
Then you should use % for zero or more chars, use _ for single char.

Lishi Liu, VSData Team
--------------------
Reply-To: "VM" <vo******@yahoo.com>
From: "VM" <vo******@yahoo.com>
Subject: Table.Select not work with '*' in middle of query...
Date: Fri, 16 Jul 2004 12:26:12 -0400
Lines: 11
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <eV*************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cvx-ppp-66-50-127-98.coqui.net 66.50.127.98
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:259348
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

If I want to run this query ( " col_output like '<del> *BOX' " ), it'll
throw an exception. How can I search for any rows that begin with '<del>'
and end with 'BOX'?
Would it also be possible to retrieve any rows that begin with '*<del>' and
end with 'BOX*' (ie. "col_output like '*<del>*BOX*' " ) ?

Thanks.



Nov 16 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.