Monday, March 26, 2012

multi from multi

Hi,
in the select i got a cell with strings like Jhon#@.#Yos#@.#Rami and i want to
check in the where cluase if one of the names (jhon, Yos or Rami) is in
(Rami, Mos, Dave (not a close list, i get it from another cell). is that
possible?
can i split the string and check for the name in one select statment?
What do i need to use? can i use decode or case?
SagiHere is an example form Anith
--Modify it for your needs
SELECT IDENTITY(INT) "n" INTO Numbers
FROM sysobjects s1
CROSS JOIN sysobjects s2
GO
DECLARE @.Ids VARCHAR(200)
SET @.Ids = '5,33,229,1,22'
SELECT SUBSTRING(@.Ids, n, CHARINDEX(',', @.Ids + ',', n) - n)
from numbers where substring(','+@.Ids,n,1)=','
AND n < LEN(@.Ids) + 1
drop table Numbers
"sagi aviram" <crisrobin@.013.net.il> wrote in message
news:440530d7$1@.news.barak.net.il...
> Hi,
> in the select i got a cell with strings like Jhon#@.#Yos#@.#Rami and i want
> to check in the where cluase if one of the names (jhon, Yos or Rami) is in
> (Rami, Mos, Dave (not a close list, i get it from another cell). is that
> possible?
> can i split the string and check for the name in one select statment?
> What do i need to use? can i use decode or case?
> Sagi
>|||I'm trying to do this like that:
SELECT request_id REQUEST_ID, parameter6 NO__OF_DAYS, parameter13 TEAM
FROM KCRT_REQUEST_DETAILS
WHERE request_type_id=30132
and (SUBSTR(replace(CONCAT(parameter13, '#@.#'), '#@.#' , ' in
([p.MULTI].TO_STRING) or '), 1, length(replace(CONCAT(parameter13, '#@.#'),
'#@.#' , ' in ([p.MULTI].TO_STRING) or '))-4) )
p.MULTI resolve to ('jhon', 'Yos', 'Rami')
the string in parameter13 is something like Jhon#@.#Yos#@.#Rami and changing.
i was thinking to add #@.# to the end of the string, replace the #@.# with the
string ' in ([p.MULTI]) or ' and then cut the 4 last letters from the end
and get (after the system will resolve the [p.MULTI] token) this:
and ('Jhon' in ('Jhon', 'Yos', 'Rami') or 'Yos' in ('Jhon', 'Yos', 'Rami')
and that will be great but the [p.MULTI] token include ' so it make it
wrong.
any help in here?
Sagi
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:OqTIZNPPGHA.812@.TK2MSFTNGP10.phx.gbl...
> Here is an example form Anith
> --Modify it for your needs
> SELECT IDENTITY(INT) "n" INTO Numbers
> FROM sysobjects s1
> CROSS JOIN sysobjects s2
> GO
> DECLARE @.Ids VARCHAR(200)
> SET @.Ids = '5,33,229,1,22'
> SELECT SUBSTRING(@.Ids, n, CHARINDEX(',', @.Ids + ',', n) - n)
> from numbers where substring(','+@.Ids,n,1)=','
> AND n < LEN(@.Ids) + 1
> drop table Numbers
>
>
> "sagi aviram" <crisrobin@.013.net.il> wrote in message
> news:440530d7$1@.news.barak.net.il...
>

No comments:

Post a Comment