Even if they did work, you would get false matches: e.g. 34 would match
a search for 3. In the second case you could write perhaps
',' + listofids + ',' LIKE '%,' + id + ',%'
but it ain't pretty.


-----Original Message-----
From: DRE [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 29 June 2005 11:00 a.m.
To: CF-Talk
Subject: OT sql with like as variable

Hey, I thought I had this down but I'm having a bit of a problem

Consider a table like so.
id, listofids
"33","33,44,55,66"
"rr","rr,gg,cc,dd"
"xx","zz,ee,rr"

I'm trying to get a list of all the records where the value of the
first is somewhere in the second.

I'm thinking
SELECT 
id,
listofids,
FROM 
table
WHERE 
CHARINDEX(id ,listofids) <> 0

Or perhaps 

SELECT 
id,
listofids
FROM 
gv_locations
WHERE 
',' + listofids + ',' LIKE '%' + id + '%'

But neither returns any records.

Any ideas?

Thanks. Andre


-- 
DRE
www.webmachineinc.com
www.theanticool.com



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210839
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to