> I have a table with a varchar field named catid. When a url variable named
> catid is passed, the page grabs all the data for that specific
> catid. Simple stuff.
>
> My problem lies in now I need for the catid to be a list
> (2,5,56,89). Thus the
> varchar field, and not a numeric. How can I select those items
> that contain
> the correct url.catid? I tried the IN keyword, with no success.

If I've got this the right way round - the CatID in the database contains
the list, and the user only passes one ID, right?

If that's the case, then you're going to have to do one of 2 thinks;
Use InStr/CharIndex to find the character
Use Like

The problems with this is that if you look for smaller digits than the
larger ones (like looking for 1) then it'll find it in things like 1, 10,
11, 21 etc. etc.
The way around this is to look for the number with commas around it - but
you've got to add commas to the start and end of the field when you're
looking, so;

Select *
from myTable
where CharIndex(',#URL.CatID#,', ',' + CatID + ',') > 0

CharIndex is the SQL Server version, if you're using Access, then it's
InStr, and the parameters are round the other way

With Like, you'd do;

Select *
from myTable
where ',' + CatID + ',' Like '%,#URL.CatID#,%'

But I haven't tried this, so it may not work

Also note that Access uses & instead of + for string concatonation

HTH

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to