Forums

ASP

This topic is locked

Using IN operator?

Posted 10 May 2002 17:15:02
1
has voted
10 May 2002 17:15:02 Martin Galabinski posted:
Help!

I have a field called CAT that stores a list like (1,2,5,7)
I want to do a query where at least one item in the list is a match.

when I try
WHERE 'MMColPARAM' in(cat)

It only returns the correct records if an exact match. How do I get it to return the records if the MMColParam is in the list?

Marty

Thanks,
Marty

Replies

Replied 11 May 2002 13:18:30
11 May 2002 13:18:30 Viktor Farcic replied:
WHERE 'MMColPARAM' LIKE cat

Viktor Farcic

TalkZone Manager
Replied 11 May 2002 17:43:17
11 May 2002 17:43:17 Martin Galabinski replied:
Viktor,
Thanks but this doesn't do it. The data in cat is stored as 1, 2, 3, 4

Each item is followed by a comma and space. If I switch the statement to
WHERE cat Like '%MMColPARAM%' then I get more than I asked for. 11 comes up if I want 1.

Is there a tutorial somewhere on using multiple select list boxes. I want to use them to add to a database and also so a person could update a database. That means refilling the list box with all items from another table and then listing them and highlighting the selected ones. Any ideas?

Marty

Thanks,
Marty
Replied 12 May 2002 04:24:59
12 May 2002 04:24:59 Andrew Watson replied:
This is an idea...

If you start your cat field with a space and end it with a comma so the content would look like this..

1, 2, 3, 4,

and not

1, 2, 3, 4

then you could simply filter the recordset like this... <pre id=code><font face=courier size=2 id=code>

WHERE Cat LIKE '% " + Request.QueryString("Category" + ",%'"</font id=code></pre id=code>

(the desired 'cat' is coming from a querystring, just replace your MMColParam here)

notice ive just searched for SPACEcatCOMMA

This seems to work.....i think

:: Son, im Thirty.... ::

Reply to this topic