I tried that as well...I tried:

Select *
>From table
Where cast(#groupID# as varchar(50)) IN (sharedGroupIDs)

Still no rows being returned.

As an extra note, the original attempt worked fine when I only have a
single value in the SharedGroupIDs column.  When I added multiple values
is when it had problems.

John

-----Original Message-----
From: George Abraham [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 19, 2004 12:30 PM
To: CF-Talk
Subject: Re: MS SQL Syntax/Operator

Use the CAST function available in T-SQL.

At 12:23 PM 5/19/2004, Burns, John D wrote:
>I have a table in MS SQL with a column that has a groupID value in it
>(int) and a column that is sharedGroupIDs (varchar).  The groupID holds

>an int of the group that the record belongs to.  The sharedGroupIDs
>holds a string of IDs that also can see the record.  I'm trying to use
>the IN keyword to find all rows where the current GroupID is either the

>groupID on a row or is IN the sharedGroupIDs column for that row.
>Here's 2 separate syntaxes I've used and the results I've gotten:
>
>select *
>from table
>where #groupID# = groupID or #groupID# IN (sharedGroupIDs)
>
>The above returns an error because SQL says it can't convert the
>SharedGroupIDs column to type of INT.  When reading about the IN
>keyword, it says that the datatypes you're comparing have to match, so
>I tried the following:
>
>select *
>from table
>where #groupID# = groupID or '#groupID#' IN (sharedGroupIDs)
>
>Notice the single quotes around #groupID# so that it should be seen as
>a string.  This doesn't produce and error, but it does not return any
>records.  A simple data test that I'm trying is #groupID# = 5 and in
>the SharedGroupIDs column I have this string: 15,7,5
>
>Any ideas on why this isn't working?  Any suggestions? Maybe another
>keyword or something I could use to produce these results?
>
>Also, just to stop unneeded responses, I can't use LIKE because if the
>value I'm searching for is 1 is and 15 is in the column, it will return

>true because there is a 1 and that's not what I'm looking for.
>
>Please help! :-)
>
>John Burns
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to