473,320 Members | 1,952 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.

using IN with LIKE

Given the following statement:

SELECT * FROM tbl
WHERE [tbl].[column] IN ('a', 'b', 'c');

I want to be able to continue using IN so how could I change it so
that each of the values passed to IN are being handled as such:

'a' becomes LIKE "*" & "a" & "*"

TIA,
Chas
Apr 11 '06 #1
2 1104
ChasW wrote:
Given the following statement:

SELECT * FROM tbl
WHERE [tbl].[column] IN ('a', 'b', 'c');

I want to be able to continue using IN so how could I change it so
that each of the values passed to IN are being handled as such:

'a' becomes LIKE "*" & "a" & "*"


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can't use wildcards in the IN predicate. You'd have to use ORs:

WHERE tbl.column Like "*a*"
OR tbl.column Like "*b*"
OR tbl.column Like "*c*"

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRDw+KoechKqOuFEgEQJNFgCg6LRsG1YzZVoVckTM+Dt11P e9wG4AoPSj
kc9L4BB8r1gtLIIKu4yX0V/X
=mtEB
-----END PGP SIGNATURE-----
Apr 11 '06 #2
MGFoster schreef:
ChasW wrote:
Given the following statement:

SELECT * FROM tbl
WHERE [tbl].[column] IN ('a', 'b', 'c');

I want to be able to continue using IN so how could I change it so
that each of the values passed to IN are being handled as such:

'a' becomes LIKE "*" & "a" & "*"


You can't use wildcards in the IN predicate. You'd have to use ORs:


In a way you can. Pass the values to IN via some table literals(literal),
then:

WHERE [tbl].[column] IN
(SELECT [tbl].[column] FROM literals
WHERE [tbl].[column] LIKE '*' & literals.literal & '*');

That's pretty lame - almost any other way would be more practical.
If values are only single letters, simply:

WHERE [tbl].[column] LIKE "*[abc]*"

--
Paul
Apr 12 '06 #3

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

Similar topics

5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
4
by: Evil Bert | last post by:
Is there anyway to compare a field with multiple string values using LIKE? Here's the statement I have now: SELECT * FROM list WHERE email LIKE CONVERT( _utf8 'hotmail@hotmail.com' USING latin1...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
47
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen,...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
12
by: bj7lewis | last post by:
I am working on a project I want to add a few files as resource to access(copy them to FS and use) at runtime. So far in VS.NET IDE, I Add Files to the project and set its Build Action to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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....

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.